[前][次][番号順一覧][スレッド一覧]

ruby-changes:64141

From: Koichi <ko1@a...>
Date: Mon, 14 Dec 2020 18:04:44 +0900 (JST)
Subject: [ruby-changes:64141] da3be76cb0 (master): add debug counters to survey the IMC miss

https://git.ruby-lang.org/ruby.git/commit/?id=da3be76cb0

From da3be76cb017c188d1a99d8aa14d13c15d93f9d1 Mon Sep 17 00:00:00 2001
From: Koichi Sasada <ko1@a...>
Date: Mon, 14 Dec 2020 17:56:34 +0900
Subject: add debug counters to survey the IMC miss


diff --git a/debug_counter.h b/debug_counter.h
index 5153f73..a4fb84d 100644
--- a/debug_counter.h
+++ b/debug_counter.h
@@ -18,6 +18,11 @@ https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L18
 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 5e77b7f..9cade36 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 https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1684
 {
     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));
 
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]