aboutsummaryrefslogtreecommitdiffstats
path: root/debug_counter.h
Commit message (Collapse)AuthorAgeFilesLines
* add debug counter to count `call` reusing cases.Koichi Sasada2019-12-171-0/+1
|
* add debug counters for vm_search_method_slowpath()卜部昌平2019-10-031-0/+10
| | | | | Implemented fine-grained inspection of cache misshits. Handy for counting the reasons why an inline method cache was evicted.
* introduce `obj_ary_extracapa`.Koichi Sasada2019-09-251-0/+1
| | | | | Introduce a new debug counter `obj_ary_extracapa` which counts arrays which are `len < capa`.
* Fix rb_define_singleton_method warningTakashi Kokubun2019-09-201-2/+2
| | | | | | | | | | | | | | | for debug counters ``` ../include/ruby/intern.h:1175:137: warning: passing argument 3 of 'rb_define_singleton_method0' from incompatible pointer type [-Wincompatible-pointer-types] #define rb_define_singleton_method(klass, mid, func, arity) rb_define_singleton_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity)); ^ ../vm.c:2958:5: note: in expansion of macro 'rb_define_singleton_method' rb_define_singleton_method(rb_cRubyVM, "show_debug_counters", rb_debug_counter_show, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/ruby/intern.h:1139:99: note: expected 'VALUE (*)(VALUE) {aka long unsigned int (*)(long unsigned int)}' but argument is of type 'VALUE (*)(void) {aka long unsigned int (*)(void)}' __attribute__((__unused__,__weakref__("rb_define_singleton_method"),__nonnull__(2,3)))static void rb_define_singleton_method0 (VALUE,const char*,VALUE(*)(VALUE),int); ```
* Add a way to print debug counters without exitingAaron Patterson2019-08-071-0/+1
| | | | | | | | I am trying to study debug counters inside a Rails application. Accessing debug counters by killing the process is hard because child processes don't get the same TRAP as the parent, and Rails seems to intercept calls to `exit`. Adding this method lets me print the debug counters when I want (at the end of requests for example)
* add debug_counters to check details.Koichi Sasada2019-08-021-1/+6
| | | | add debug_counters to check the Hash object statistics.
* Use 1 byte hint for ar_table [Feature #15602]Koichi Sasada2019-07-311-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On ar_table, Do not keep a full-length hash value (FLHV, 8 bytes) but keep a 1 byte hint from a FLHV (lowest byte of FLHV). An ar_table only contains at least 8 entries, so hints consumes 8 bytes at most. We can store hints in RHash::ar_hint. On 32bit CPU, we use 4 entries ar_table. The advantages: * We don't need to keep FLHV so ar_table only consumes 16 bytes (VALUEs of key and value) * 8 entries = 128 bytes. * We don't need to scan ar_table, but only need to check hints in many cases. Especially we don't need to access ar_table if there is no match entries (in many cases). It will increase memory cache locality. The disadvantages: * This technique can increase `#eql?` time because hints can conflicts (in theory, it conflicts once in 256 times). It can introduce incompatibility if there is a object x where x.eql? returns true even if hash values are different. I believe we don't need to care such irregular case. * We need to re-calculate FLHV if we need to switch from ar_table to st_table (e.g. exceeds 8 entries). It also can introduce incompatibility, on mutating key objects. I believe we don't need to care such irregular case too. Add new debug counters to measure the performance: * artable_hint_hit - hint is matched and eql?#=>true * artable_hint_miss - hint is not matched but eql?#=>false * artable_hint_notfound - lookup counts
* fix debug counter for Hash counts.Koichi Sasada2019-07-191-6/+6
| | | | | | | | | | | | | | | | | | | Change debug_counters for Hash object counts: * obj_hash_under4 (1-3) -> obj_hash_1_4 (1-4) * obj_hash_ge4 (4-7) -> obj_hash_5_8 (5-8) * obj_hash_ge8 (>=8) -> obj_hash_g8 (> 8) For example on rdoc benchmark: [RUBY_DEBUG_COUNTER] obj_hash_empty 554,900 [RUBY_DEBUG_COUNTER] obj_hash_under4 572,998 [RUBY_DEBUG_COUNTER] obj_hash_ge4 1,825 [RUBY_DEBUG_COUNTER] obj_hash_ge8 2,344 [RUBY_DEBUG_COUNTER] obj_hash_empty 553,097 [RUBY_DEBUG_COUNTER] obj_hash_1_4 571,880 [RUBY_DEBUG_COUNTER] obj_hash_5_8 982 [RUBY_DEBUG_COUNTER] obj_hash_g8 2,189
* fix shared array terminology.Koichi Sasada2019-07-191-0/+9
| | | | | | | | | | | | | | | | | | Shared arrays created by Array#dup and so on points a shared_root object to manage lifetime of Array buffer. However, sometimes shared_root is called only shared so it is confusing. So I fixed these wording "shared" to "shared_root". * RArray::heap::aux::shared -> RArray::heap::aux::shared_root * ARY_SHARED() -> ARY_SHARED_ROOT() * ARY_SHARED_NUM() -> ARY_SHARED_ROOT_REFCNT() Also, add some debug_counters to count shared array objects. * ary_shared_create: shared ary by Array#dup and so on. * ary_shared: finished in shard. * ary_shared_root_occupied: shared_root but has only 1 refcnt. The number (ary_shared - ary_shared_root_occupied) is meaningful.
* Reduce ONIG_NREGION from 10 to 4: power of 2 and testing revealed most ↵Lourens Naudé2019-05-071-0/+6
| | | | | | pattern matches are less than or equal to 4 results Closes: https://github.com/ruby/ruby/pull/2135
* add new debug_counters about is_pointer_to_heap().Koichi Sasada2019-05-071-0/+5
| | | | | is_pointer_to_heap() is used for conservative marking. To analyze this function's behavior, introduce some debug_counters.
* Invalidate JIT-ed code if ISeq is moved by GC.compactk0kubun2019-04-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix missing debug counter namek0kubun2019-04-141-1/+1
| | | | | | r67550 introduced the typo git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counter for MJIT stale_unitsk0kubun2019-04-141-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add RubyVM.reset_debug_counters when RB_DEBUG_COUNTERk0kubun2019-04-141-0/+2
| | | | | | is defined. It's 0 by default and so it dissappears on actual build. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counter for VM <-> MJIT callsk0kubun2019-04-061-0/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67460 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add mjit_compile_failures debug counterk0kubun2019-03-291-0/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counters for MJIT cancelk0kubun2019-03-291-1/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counter for rb_mjit_unit_listk0kubun2019-03-291-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67378 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix a typo [ci skip]kazu2019-03-291-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counters for MJITk0kubun2019-03-291-0/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Elaborate more on some debug counters [ci skip]k0kubun2019-03-291-7/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add debug counters to count call cache fastpath.ko12019-03-221-0/+22
| | | | | | | | | Add counters to count ccf (call cache fastpath) usage. These counters will help which kind of method dispatch is important to optimize. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67336 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename li_table->ar_table (and related names).ko12018-12-141-1/+1
| | | | | | | | | | | | | | | | | | | * internal.h: rename the following names: * li_table -> ar_table. "li" means linear (from linear search), but we use the word "array" (from data layout). * RHASH_ARRAY -> RHASH_AR_TABLE. AR_TABLE is more clear. * rb_hash_array_* -> rb_hash_ar_table_*. * RHASH_TABLE_P() -> RHASH_ST_TABLE_P(). more clear. * RHASH_CLEAR() -> RHASH_ST_CLEAR(). * hash.c: rename "linear_" prefix functions to "ar_" prefix. * hash.c (linear_init_table): rename to ar_alloc_table. * debug_counter.h: rename obj_hash_array to obj_hash_ar. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66390 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_HASH. [Feature #14989]ko12018-10-301-0/+5
| | | | | | | | | | | | | | | | | * hash.c, internal.h: support theap for small Hash. Introduce RHASH_ARRAY (li_table) besides st_table and small Hash (<=8 entries) are managed by an array data structure. This array data can be managed by theap. If st_table is needed, then converting array data to st_table data. For st_table using code, we prepare "stlike" APIs which accepts hash value and are very similar to st_ APIs. This work is based on the GSoC achievement by tacinight <tacingiht@gmail.com> and refined by ko1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_STRUCT.ko12018-10-301-1/+2
| | | | | | | * struct.c: members memory can use theap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_OBJECT.ko12018-10-301-2/+5
| | | | | | | | | | * variable.c: now instance variable space has theap supports. obj_ivar_heap_alloc() tries to acquire memory from theap. * debug_counter.h: add some counters for theap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce TransientHeap. [Bug #14858]ko12018-10-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * transient_heap.c, transient_heap.h: implement TransientHeap (theap). theap is designed for Ruby's object system. theap is like Eden heap on generational GC terminology. theap allocation is very fast because it only needs to bump up pointer and deallocation is also fast because we don't do anything. However we need to evacuate (Copy GC terminology) if theap memory is long-lived. Evacuation logic is needed for each type. See [Bug #14858] for details. * array.c: Now, theap for T_ARRAY is supported. ary_heap_alloc() tries to allocate memory area from theap. If this trial sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on. We don't need to free theap ptr. * ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that if ary is allocated at theap, force evacuation to malloc'ed memory. It makes programs slow, but very compatible with current code because theap memory can be evacuated (theap memory will be recycled). If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT() instead of RARRAY_CONST_PTR(). If you can't understand when evacuation will occur, use RARRAY_CONST_PTR(). (re-commit of r65444) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65449 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert r65444 and r65446 because of commit missko12018-10-301-10/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* support theap for T_OBJECT.ko12018-10-301-2/+5
| | | | | | | | | | * variable.c: now instance variable space has theap supports. obj_ivar_heap_alloc() tries to acquire memory from theap. * debug_counter.h: add some counters for theap. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65446 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* introduce TransientHeap. [Bug #14858]ko12018-10-301-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * transient_heap.c, transient_heap.h: implement TransientHeap (theap). theap is designed for Ruby's object system. theap is like Eden heap on generational GC terminology. theap allocation is very fast because it only needs to bump up pointer and deallocation is also fast because we don't do anything. However we need to evacuate (Copy GC terminology) if theap memory is long-lived. Evacuation logic is needed for each type. See [Bug #14858] for details. * array.c: Now, theap for T_ARRAY is supported. ary_heap_alloc() tries to allocate memory area from theap. If this trial sccesses, this array has theap ptr and RARRAY_TRANSIENT_FLAG is turned on. We don't need to free theap ptr. * ruby.h: RARRAY_CONST_PTR() returns malloc'ed memory area. It menas that if ary is allocated at theap, force evacuation to malloc'ed memory. It makes programs slow, but very compatible with current code because theap memory can be evacuated (theap memory will be recycled). If you want to get transient heap ptr, use RARRAY_CONST_PTR_TRANSIENT() instead of RARRAY_CONST_PTR(). If you can't understand when evacuation will occur, use RARRAY_CONST_PTR(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65444 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add new counter about GC.ko12018-10-251-0/+1
| | | | | | | * debug_counter.h: add `gc_major_oldmalloc`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65362 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add new debug_counters for GC.ko12018-10-241-0/+19
| | | | | | | * debug_counter.h: add new debug counters to count GC. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add debug counters more.ko12018-09-281-0/+10
| | | | | | | | | | | | | * debug_counter.h: add debug counters to count frame state transitions: * frame_R2R: Ruby frame to Ruby frame * frame_R2C: Ruby frame to C frame * frame_C2C: C frame to C frame * frame_C2R: C frame to Ruby frame * vm_insnhelper.c (vm_push_frame): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add debug counters more.ko12018-09-281-3/+53
| | | | | | | | | | | | | | | | | * debug_counter.h: add the following counters. * frame_push: control frame counts (total counts). * frame_push_*: control frame counts per every frame type. * obj_*: add free'ed counts for each type. * gc.c: ditto. * vm_insnhelper.c (vm_push_frame): ditto. * debug_counter.c (rb_debug_counter_show_results): widen counts field to show >10G numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64867 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add some debug counters.ko12018-09-261-0/+8
| | | | | | | | | | * debug_counter.h: new debug counters obj_promote, obj_wb_unprotect and obj_struct_(ptr|embed) are added. * gc.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* refactoring debug_counter.ko12018-09-251-9/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * debug_counter.h: add comments for each counters. * debug_counter.h: add some counters (see added comments for details). * obj_newobj * obj_newobj_slowpath * obj_newobj_wb_unprotected * obj_hash_empty * obj_hash_under4 * obj_hash_ge4 * obj_hash_ge8 * heap_xmalloc * heap_xrealloc * heap_xfree * gc.c: add some debug counters (see the above list). * debug_counter.c (rb_debug_counter_show_results): accept a header message. * signal.c (ruby_default_signal): show debug counter results and malloc info (rb_malloc_info_show_results()) before SIGNAL exit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* debug_counter.h: include __FILE__ to recursenobu2018-02-091-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename absolute_path to realpath internally and introduce pathobj.ko12017-06-011-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * vm_core.h: rename absolute_path to realpath because it is expected name. external APIs (#absolute_path methods) are remained. * vm_core.h: remove rb_iseq_location_struct::path and rb_iseq_location_struct::absolute_path and introduce pathobj. if given path equals to given absolute_path (and most of case it is true), pathobj is simply given path String. If it is not same, pathobj is Array and pathobj[0] is path and pathobj[1] is realpath. This size optimization reduce 8 bytes and sizeof(struct rb_iseq_constant_body) is 200 bytes -> 192 bytes on 64bit CPU. To support this change, the following functions are introduced: * pathobj_path() (defined in vm_core.h) * pathobj_realpath() (ditto) * rb_iseq_path() (decl. in vm_core.h) * rb_iseq_realpath() (ditto) * rb_iseq_pathobj_new() (ditto) * rb_iseq_pathobj_set() (ditto) * vm_core.h (rb_binding_t): use pathobj instead of path. If binding is given at eval methods, realpath (absolute_path) was caller's realpath. However, they should use binding's realpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add debug counters for local variable (lavr) access.ko12017-05-311-0/+10
| | | | | | | | | | | | * debug_counter.h: add the following counters: * lvar_get: counter for lvar get. * lvar_get_dynamic: counter for lvar get from upper frames. * lvar_set: coutner for lvar set. * lvar_set_dynamic: coutner for lvar set from upper frames. * lvar_set_slowpath: counter for lavr set using slowpath. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add debug counters.ko12017-05-241-0/+16
| | | | | | | | | | | | | | | | | * debug_counter.h: add the following counters to measure object types. obj_free: freed count obj_str_ptr: freed count of Strings they have extra buff. obj_str_embed: freed count of Strings they don't have extra buff. obj_str_shared: freed count of Strings they have shared extra buff. obj_str_nofree: freed count of Strings they are marked as nofree. obj_str_fstr: freed count of Strings they are marked as fstr. obj_ary_ptr: freed count of Arrays they have extra buff. obj_ary_embed: freed count of Arrays they don't have extra buff. obj_obj_ptr: freed count of Objects (T_OBJECT) they have extra buff. obj_obj_embed: freed count of Objects they don't have extra buff. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add several counters to analyze ivar inline caches.ko12017-03-151-6/+13
| | | | | | | | | | | | | | | | | | | | | | * debug_counter.h: add (and renamed) several counters: ivar_get_ic_hit ivar_get_ic_miss ivar_get_ic_miss_serial ivar_get_ic_miss_unset ivar_get_ic_miss_noobject ivar_set_ic_hit ivar_set_ic_miss ivar_set_ic_miss_serial ivar_set_ic_miss_unset ivar_set_ic_miss_oorange ivar_set_ic_miss_noobject ivar_get_base ivar_set_base See related source code to know what counters mean. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* debug_counter.c: debug_counter_names [ci skip]nobu2017-03-101-21/+25
| | | | | | | | | | * debug_counter.c (debug_counter_names): stringize debug counter names by preprocessor. * debug_counter.h (RB_DEBUG_COUNTER): define counter names outside the include guard, to expand multiple times. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add performance counting mechanism for MRI debug/tuning purpose.ko12017-02-211-0/+67
* How to enable this feature? * define USE_DEBUG_COUNTER as 1. * you can disable to output the result with RUBY_DEBUG_COUNTER_DISABLE environment variable even if USE_DEBUG_COUNTER == 1. * How to add new counter? * add COUNTER(<name>) line on debug_counter.h. * include "debug_counter.h" * insert RB_DEBUG_COUNTER_INC(<name>) line on your favorite place. * counter output example: [RUBY_DEBUG_COUNTER] mc_inline_hit 999 [RUBY_DEBUG_COUNTER] mc_inline_miss 3 [RUBY_DEBUG_COUNTER] mc_global_hit 23 [RUBY_DEBUG_COUNTER] mc_global_miss 273 [RUBY_DEBUG_COUNTER] mc_global_state_miss 3 [RUBY_DEBUG_COUNTER] mc_class_serial_miss 0 [RUBY_DEBUG_COUNTER] mc_cme_complement 0 [RUBY_DEBUG_COUNTER] mc_cme_complement_hit 0 [RUBY_DEBUG_COUNTER] mc_search_super 1384 [RUBY_DEBUG_COUNTER] ivar_get_hit 0 [RUBY_DEBUG_COUNTER] ivar_get_miss 0 [RUBY_DEBUG_COUNTER] ivar_set_hit 0 [RUBY_DEBUG_COUNTER] ivar_set_miss 0 [RUBY_DEBUG_COUNTER] ivar_get 431 [RUBY_DEBUG_COUNTER] ivar_set 465 * mc_... is related to method caching. * ivar_... is related to instance variable accesses. * compare with dtrace/system tap features, there are completely no performacne penalties when it is disabled. * This feature is supported only on __GNUC__ compilers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e