ruby-changes:52641
From: ko1 <ko1@a...>
Date: Wed, 26 Sep 2018 16:28:11 +0900 (JST)
Subject: [ruby-changes:52641] ko1:r64853 (trunk): add some debug counters.
ko1 2018-09-26 16:28:04 +0900 (Wed, 26 Sep 2018) New Revision: 64853 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=64853 Log: add some debug counters. * debug_counter.h: new debug counters obj_promote, obj_wb_unprotect and obj_struct_(ptr|embed) are added. * gc.c: ditto. Modified files: trunk/debug_counter.h trunk/gc.c Index: gc.c =================================================================== --- gc.c (revision 64852) +++ gc.c (revision 64853) @@ -1200,6 +1200,7 @@ RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(rb_obj https://github.com/ruby/ruby/blob/trunk/gc.c#L1200 static inline void RVALUE_OLD_UNCOLLECTIBLE_SET(rb_objspace_t *objspace, VALUE obj) { + RB_DEBUG_COUNTER_INC(obj_promote); RVALUE_PAGE_OLD_UNCOLLECTIBLE_SET(objspace, GET_HEAP_PAGE(obj), obj); } @@ -2366,7 +2367,11 @@ obj_free(rb_objspace_t *objspace, VALUE https://github.com/ruby/ruby/blob/trunk/gc.c#L2367 if ((RBASIC(obj)->flags & RSTRUCT_EMBED_LEN_MASK) == 0 && RANY(obj)->as.rstruct.as.heap.ptr) { xfree((void *)RANY(obj)->as.rstruct.as.heap.ptr); + RB_DEBUG_COUNTER_INC(obj_struct_ptr); } + else { + RB_DEBUG_COUNTER_INC(obj_struct_embed); + } break; case T_SYMBOL: @@ -6053,6 +6058,7 @@ rb_gc_writebarrier_unprotect(VALUE obj) https://github.com/ruby/ruby/blob/trunk/gc.c#L6058 RVALUE_AGE_RESET(obj); } + RB_DEBUG_COUNTER_INC(obj_wb_unprotect); MARK_IN_BITMAP(GET_HEAP_WB_UNPROTECTED_BITS(obj), obj); } } Index: debug_counter.h =================================================================== --- debug_counter.h (revision 64852) +++ debug_counter.h (revision 64853) @@ -81,6 +81,8 @@ RB_DEBUG_COUNTER(lvar_set_slowpath) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L81 * * obj_newobj_slowpath: newobj with slowpath counts * * obj_newobj_wb_unprotected: newobj for wb_unprotecte. * * obj_free: obj_free() counts + * * obj_promote: promoted counts (oldgen) + * * obj_wb_unprotect: wb unprotect counts * * * obj_[type]_[attr]: free'ed counts for each type. * * [type] @@ -88,6 +90,7 @@ RB_DEBUG_COUNTER(lvar_set_slowpath) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L90 * * _str: T_STRING * * _ary: T_ARRAY * * _hash: T_HASH + * * _struct: T_STRUCT * * * [attr] * * _ptr: R?? is not embed. @@ -105,6 +108,8 @@ RB_DEBUG_COUNTER(obj_newobj) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L108 RB_DEBUG_COUNTER(obj_newobj_slowpath) RB_DEBUG_COUNTER(obj_newobj_wb_unprotected) RB_DEBUG_COUNTER(obj_free) +RB_DEBUG_COUNTER(obj_promote) +RB_DEBUG_COUNTER(obj_wb_unprotect) RB_DEBUG_COUNTER(obj_obj_ptr) RB_DEBUG_COUNTER(obj_obj_embed) @@ -123,6 +128,9 @@ RB_DEBUG_COUNTER(obj_hash_under4) https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L128 RB_DEBUG_COUNTER(obj_hash_ge4) RB_DEBUG_COUNTER(obj_hash_ge8) +RB_DEBUG_COUNTER(obj_struct_ptr) +RB_DEBUG_COUNTER(obj_struct_embed) + /* heap function counts * * * heap_xmalloc/realloc/xfree: call counts -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/