Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug counters to RubyVM.stat #6086

Merged
merged 3 commits into from Dec 8, 2022

Conversation

chrisseaton
Copy link
Contributor

For example I use this like this

def foo
  14
end

before = RubyVM.stat

10.times do
  foo
end

after = RubyVM.stat

pp after.map { |k, v| [k, v - (before[k] || 0)] }.to_h.select { |k, v| v > 0 }
{:constant_cache_misses=>1,
 :mc_inline_hit=>9,
 :mc_inline_miss_klass=>3,
 :mc_inline_miss_diff=>3,
 :mc_search=>2,
 :mc_search_super=>3,
 :cc_new=>2,
 :cc_found_in_ccs=>1,
 :cc_not_found_in_ccs=>2,
 :ccs_not_found=>2,
 :ccf_general=>2,
 :ccf_iseq_setup=>1,
 :ccf_iseq_fix=>9,
 :ccf_cfunc=>1,
 :ccf_cfunc_with_frame=>2,
 :frame_push=>22,
 :frame_push_method=>10,
 :frame_push_block=>10,
 :frame_push_cfunc=>2,
 :frame_R2R=>10,
 :frame_R2C=>2,
 :frame_C2R=>10,
 :lvar_set=>1,
 :lvar_set_slowpath=>1,
 :obj_newobj=>319,
 :artable_hint_miss=>1,
 :artable_hint_notfound=>8,
 :heap_xmalloc=>41,
 :heap_xfree=>9,
 :theap_alloc=>1,
 :vm_sync_lock_enter=>262,
 :vm_sync_lock_enter_nb=>1}

debug_counter.c Outdated Show resolved Hide resolved
vm.c Outdated Show resolved Hide resolved
vm.c Outdated Show resolved Hide resolved
@chrisseaton chrisseaton force-pushed the ruby-vm-stat-debug-counters branch 2 times, most recently from bc559cd to 5ca858c Compare July 6, 2022 16:19
@chrisseaton chrisseaton requested a review from nobu July 6, 2022 17:03
@chrisseaton
Copy link
Contributor Author

I think all previous review points have been addressed.

@k0kubun
Copy link
Member

k0kubun commented Dec 8, 2022

I wonder if it's enough to separately define it as RubyVM.debug_counters like other USE_DEBUG_COUNTER-only methods, but looking at the use case, I think he wanted to compare all VM stats together and this would have been more useful for him. Given that it's USE_DEBUG_COUNTER-only and we could move it at any time, I'll merge this as is. Thank you, Chris.

@k0kubun k0kubun merged commit 645cd94 into ruby:master Dec 8, 2022
matzbot pushed a commit that referenced this pull request Dec 19, 2022
k0kubun added a commit that referenced this pull request Dec 19, 2022
This reverts commit 6229c02.

Nothing has been changed in RubyVM.stat on normal Ruby build. It seems
confusing to say that something has been changed there. The flag is
supposed to be enabled only by CRuby developers, and it's not efficient
enough for public consumption.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants