summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-21 08:18:15 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-21 08:18:15 +0000
commit76c4cca19c0c27b1c3ca6f597384707cccf3de06 (patch)
treebcb13fed3f68e50cbca8a4bd475157d9bfeb7dca /vm_method.c
parent51de3aa2b27859305c74d5664724192602c4608f (diff)
add performance counting mechanism for MRI debug/tuning purpose.
* 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
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/vm_method.c b/vm_method.c
index 00b2763e5d..63b8aad9c7 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -695,6 +695,7 @@ search_method(VALUE klass, ID id, VALUE *defined_class_ptr)
rb_method_entry_t *me;
for (me = 0; klass; klass = RCLASS_SUPER(klass)) {
+ RB_DEBUG_COUNTER_INC(mc_search_super);
if ((me = lookup_method_table(klass, id)) != 0) break;
}
@@ -778,10 +779,12 @@ method_entry_get(VALUE klass, ID id, VALUE *defined_class_ptr)
verify_method_cache(klass, id, ent->defined_class, ent->me);
#endif
if (defined_class_ptr) *defined_class_ptr = ent->defined_class;
+ RB_DEBUG_COUNTER_INC(mc_global_hit);
return ent->me;
}
#endif
+ RB_DEBUG_COUNTER_INC(mc_global_miss);
return method_entry_get_without_cache(klass, id, defined_class_ptr);
}
@@ -798,6 +801,7 @@ prepare_callable_method_entry(VALUE defined_class, ID id, const rb_method_entry_
const rb_callable_method_entry_t *cme;
if (me && me->defined_class == 0) {
+ RB_DEBUG_COUNTER_INC(mc_cme_complement);
VM_ASSERT(RB_TYPE_P(defined_class, T_ICLASS) || RB_TYPE_P(defined_class, T_MODULE));
VM_ASSERT(me->defined_class == 0);
@@ -806,6 +810,7 @@ prepare_callable_method_entry(VALUE defined_class, ID id, const rb_method_entry_
}
if (rb_id_table_lookup(mtbl, id, (VALUE *)&me)) {
+ RB_DEBUG_COUNTER_INC(mc_cme_complement_hit);
cme = (rb_callable_method_entry_t *)me;
VM_ASSERT(callable_method_entry_p(cme));
}