diff options
author | Kevin Newton <kddnewton@gmail.com> | 2022-04-05 16:37:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 16:37:00 -0400 |
commit | 8ee4a82e8cfe6f39abeb60013447bdd2a3a3c61f (patch) | |
tree | 98de69b8cf48b6af86e980897c4563514280af0f /vm_insnhelper.h | |
parent | 5571ca3aa2029789e968fe8b13e176fa98fcea36 (diff) |
RubyVM.stat constant cache metrics (#5766)
Before the new constant cache behavior, caches were invalidated by a
single global variable. You could inspect the value of this variable
with RubyVM.stat(:global_constant_state). This was mostly useful to
verify the behavior of the VM or to test constant loading like in Rails.
With the new constant cache behavior, we introduced
RubyVM.stat(:constant_cache) which returned a hash with symbol keys and
integer values that represented the number of live constant caches
associated with the given symbol. Additionally, we removed the old
RubyVM.stat(:global_constant_state).
This was proven to be not very useful, so it doesn't help you diagnose
constant loading issues. So, instead we added the global constant state
back into the RubyVM output. However, that number can be misleading as
now when you invalidate something like `Foo::Bar::Baz` you're actually
invalidating 3 different lists of inline caches.
This commit attempts to get the best of both worlds. We remove
RubyVM.stat(:global_constant_state) like we did originally, as it
doesn't have the same semantic meaning and it could be confusing going
forward. Instead we add RubyVM.stat(:constant_cache_invalidations) and
RubyVM.stat(:constant_cache_misses). These two metrics should provide
enough information to diagnose any constant loading issues, as well as
provide a replacement for the old global constant state.
Notes
Notes:
Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'vm_insnhelper.h')
-rw-r--r-- | vm_insnhelper.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/vm_insnhelper.h b/vm_insnhelper.h index 5506fca4d6..126867025f 100644 --- a/vm_insnhelper.h +++ b/vm_insnhelper.h @@ -14,7 +14,8 @@ MJIT_SYMBOL_EXPORT_BEGIN RUBY_EXTERN VALUE ruby_vm_const_missing_count; -RUBY_EXTERN rb_serial_t ruby_vm_global_constant_state; +RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_invalidations; +RUBY_EXTERN rb_serial_t ruby_vm_constant_cache_misses; RUBY_EXTERN rb_serial_t ruby_vm_class_serial; RUBY_EXTERN rb_serial_t ruby_vm_global_cvar_state; |