summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2022-04-05 16:37:00 -0400
committerGitHub <noreply@github.com>2022-04-05 16:37:00 -0400
commit8ee4a82e8cfe6f39abeb60013447bdd2a3a3c61f (patch)
tree98de69b8cf48b6af86e980897c4563514280af0f /vm_method.c
parent5571ca3aa2029789e968fe8b13e176fa98fcea36 (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_method.c')
-rw-r--r--vm_method.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index 81e88a32c1..36a2c15e4b 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -144,10 +144,10 @@ rb_clear_constant_cache_for_id(ID id)
if (rb_id_table_lookup(vm->constant_cache, id, (VALUE *) &ics)) {
st_foreach(ics, rb_clear_constant_cache_for_id_i, (st_data_t) NULL);
+ ruby_vm_constant_cache_invalidations += ics->num_entries;
}
rb_yjit_constant_state_changed();
- ruby_vm_global_constant_state++;
}
static void