mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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.
This commit is contained in:
parent
d0b5f31554
commit
c8ddc0a843
Notes:
git
2025-06-09 03:33:51 +00:00
9 changed files with 111 additions and 17 deletions
1
gc/gc.h
1
gc/gc.h
|
@ -31,6 +31,7 @@ enum rb_gc_vm_weak_tables {
|
|||
RB_GC_VM_ID2REF_TABLE,
|
||||
RB_GC_VM_GENERIC_FIELDS_TABLE,
|
||||
RB_GC_VM_FROZEN_STRINGS_TABLE,
|
||||
RB_GC_VM_CC_REFINEMENT_TABLE,
|
||||
RB_GC_VM_WEAK_TABLE_COUNT
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue