summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-12-14 17:56:34 +0900
committerKoichi Sasada <ko1@atdot.net>2020-12-14 17:56:34 +0900
commitda3be76cb017c188d1a99d8aa14d13c15d93f9d1 (patch)
tree1e5b3b22eebb0adce5799eb39e48339c786e3eca
parentaacd2295d0f2c982641229e159ff179462d83a36 (diff)
add debug counters to survey the IMC miss
-rw-r--r--debug_counter.h5
-rw-r--r--vm_insnhelper.c19
2 files changed, 24 insertions, 0 deletions
diff --git a/debug_counter.h b/debug_counter.h
index 5153f73a6a..a4fb84dbdc 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -18,6 +18,11 @@
RB_DEBUG_COUNTER(mc_inline_hit) // IMC hit
RB_DEBUG_COUNTER(mc_inline_miss_klass) // IMC miss by different class
RB_DEBUG_COUNTER(mc_inline_miss_invalidated) // IMC miss by invalidated ME
+RB_DEBUG_COUNTER(mc_inline_miss_empty) // IMC miss because prev is empty slot
+RB_DEBUG_COUNTER(mc_inline_miss_same_cc) // IMC miss, but same CC
+RB_DEBUG_COUNTER(mc_inline_miss_same_cme) // IMC miss, but same CME
+RB_DEBUG_COUNTER(mc_inline_miss_diff) // IMC miss, different methods
+
RB_DEBUG_COUNTER(mc_cme_complement) // number of acquiring complement CME
RB_DEBUG_COUNTER(mc_cme_complement_hit) // number of cache hit for complemented CME
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 5e77b7fbf2..9cade36fad 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1684,8 +1684,27 @@ rb_vm_search_method_slowpath(VALUE cd_owner, struct rb_call_data *cd, VALUE klas
{
RB_VM_LOCK_ENTER();
{
+#if USE_DEBUG_COUNTER
+ const struct rb_callcache *old_cc = cd->cc;
+#endif
const struct rb_callcache *cc = vm_search_cc(klass, cd->ci);
+#if USE_DEBUG_COUNTER
+ if (old_cc == &vm_empty_cc) {
+ // empty
+ RB_DEBUG_COUNTER_INC(mc_inline_miss_empty);
+ }
+ else if (old_cc == cd->cc) {
+ RB_DEBUG_COUNTER_INC(mc_inline_miss_same_cc);
+ }
+ else if (vm_cc_cme(old_cc) == vm_cc_cme(cc)) {
+ RB_DEBUG_COUNTER_INC(mc_inline_miss_same_cme);
+ }
+ else {
+ RB_DEBUG_COUNTER_INC(mc_inline_miss_diff);
+ }
+#endif
+
VM_ASSERT(cc);
VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache));