diff options
author | alpaca-tc <[email protected]> | 2025-04-06 01:50:08 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2025-06-09 12:33:35 +0900 |
commit | c8ddc0a843074811b200673a2019fbe4b50bb890 (patch) | |
tree | f3881cd1f408f10abfdd7a8258d88cf18a557717 /st.c | |
parent | d0b5f3155406e8243b78e4cedd3a38710c7c323c (diff) |
Optimize callcache invalidation for refinements
Fixes [Bug #21201]
This change addresses a performance regression where defining methods
inside `refine` blocks caused severe slowdowns. The issue was due to
`rb_clear_all_refinement_method_cache()` triggering a full object
space scan via `rb_objspace_each_objects` to find and invalidate
affected callcaches, which is very inefficient.
To fix this, I introduce `vm->cc_refinement_table` to track
callcaches related to refinements. This allows us to invalidate
only the necessary callcaches without scanning the entire heap,
resulting in significant performance improvement.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/13077
Diffstat (limited to 'st.c')
-rw-r--r-- | st.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -2465,6 +2465,12 @@ set_init_numtable(void) return set_init_table_with_size(NULL, &type_numhash, 0); } +set_table * +set_init_numtable_with_size(st_index_t size) +{ + return set_init_table_with_size(NULL, &type_numhash, size); +} + size_t set_table_size(const struct set_table *tbl) { |