add debug counters to survey the IMC miss

This commit is contained in:
Koichi Sasada 2020-12-14 17:56:34 +09:00
parent aacd2295d0
commit da3be76cb0
2 changed files with 24 additions and 0 deletions

View File

@ -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

View File

@ -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));