diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-26 16:43:21 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-26 16:43:21 +0000 |
commit | ca2ca7d32b7ac53b9c28fac36dfe0bc539df85c6 (patch) | |
tree | 18ed7caf139eff127052aab43765ede6246f55a5 | |
parent | c4c821a7d7f2229a7c8d2c36cdc6b20668101081 (diff) |
* gc.c (gc_stat): collect shade_operation_count,
remembered_sunny_object_count and remembered_shady_object_count
for each types when RGENGC_PROFILE >= 2.
They are informative for optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40938 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | gc.c | 45 |
2 files changed, 43 insertions, 9 deletions
@@ -1,3 +1,10 @@ +Mon May 27 01:40:58 2013 Koichi Sasada <ko1@atdot.net> + + * gc.c (gc_stat): collect shade_operation_count, + remembered_sunny_object_count and remembered_shady_object_count + for each types when RGENGC_PROFILE >= 2. + They are informative for optimization. + Mon May 27 01:15:22 2013 Koichi Sasada <ko1@atdot.net> * hash.c (rb_hash_tbl_raw), internal.h: added. @@ -330,6 +330,9 @@ typedef struct rb_objspace { size_t remembered_shady_object_count; #if RGENGC_PROFILE >= 2 size_t generated_shady_object_count_types[RUBY_T_MASK]; + size_t shade_operation_count_types[RUBY_T_MASK]; + size_t remembered_sunny_object_count_types[RUBY_T_MASK]; + size_t remembered_shady_object_count_types[RUBY_T_MASK]; #endif #endif /* RGENGC_PROFILE */ #endif /* USE_RGENGC */ @@ -3499,8 +3502,18 @@ rgengc_remember(rb_objspace_t *objspace, VALUE obj) if (RGENGC_PROFILE) { if (!rgengc_remembered(objspace, obj)) { - if (RVALUE_SUNNY(obj)) objspace->profile.remembered_sunny_object_count++; - else objspace->profile.remembered_shady_object_count++; + if (RVALUE_SUNNY(obj)) { + objspace->profile.remembered_sunny_object_count++; +#if RGENGC_PROFILE >= 2 + objspace->profile.remembered_sunny_object_count_types[BUILTIN_TYPE(obj)]++; +#endif + } + else { + objspace->profile.remembered_shady_object_count++; +#if RGENGC_PROFILE >= 2 + objspace->profile.remembered_shady_object_count_types[BUILTIN_TYPE(obj)]++; +#endif + } } } @@ -3617,6 +3630,9 @@ rb_gc_giveup_promoted_writebarrier(VALUE obj) #if RGENGC_PROFILE objspace->profile.shade_operation_count++; +#if RGENGC_PROFILE >= 2 + objspace->profile.shade_operation_count_types[BUILTIN_TYPE(obj)]++; +#endif /* RGENGC_PROFILE >= 2 */ #endif } @@ -3859,6 +3875,20 @@ rb_during_gc(void) return during_gc; } +#if RGENGC_PROFILE >= 2 +static void +gc_count_add_each_types(VALUE hash, const char *name, size_t *types) +{ + VALUE result = rb_hash_new(); + int i; + for (i=0; i<T_MASK; i++) { + const char *type = type_name(i, 0); + rb_hash_aset(result, ID2SYM(rb_intern(type)), SIZET2NUM(types[i])); + } + rb_hash_aset(hash, ID2SYM(rb_intern(name)), result); +} +#endif + /* * call-seq: * GC.count -> Integer @@ -3978,13 +4008,10 @@ gc_stat(int argc, VALUE *argv, VALUE self) rb_hash_aset(hash, sym_remembered_shady_object_count, SIZET2NUM(objspace->profile.remembered_shady_object_count)); #if RGENGC_PROFILE >= 2 { - VALUE types = rb_hash_new(); - int i; - for (i=0; i<T_MASK; i++) { - const char *type = type_name(i, 0); - rb_hash_aset(types, ID2SYM(rb_intern(type)), SIZET2NUM(objspace->profile.generated_shady_object_count_types[i])); - } - rb_hash_aset(hash, ID2SYM(rb_intern("generated_shady_object_count_types")), types); + gc_count_add_each_types(hash, "generated_shady_object_count_types", objspace->profile.generated_shady_object_count_types); + gc_count_add_each_types(hash, "shade_operation_count_types", objspace->profile.shade_operation_count_types); + gc_count_add_each_types(hash, "remembered_sunny_object_count_types", objspace->profile.remembered_sunny_object_count_types); + gc_count_add_each_types(hash, "remembered_shady_object_count_types", objspace->profile.remembered_shady_object_count_types); } #endif #endif /* RGENGC_PROFILE */ |