Use rb_gc_mark_weak for cc->klass.

One of the biggest remaining contention point is `RClass.cc_table`.
The logical solution would be to turn it into a managed object, so
we can use an RCU strategy, given it's read heavy.

However, that's not currently possible because the table can't
be freed before the owning class, given the class free function
MUST go over all the CC entries to invalidate them.

However if the `CC->klass` reference is weak marked, then the
GC will take care of setting the reference to `Qundef`.
This commit is contained in:
Jean Boussier 2025-07-29 15:13:01 +02:00
parent 1055e04e28
commit fc5e1541e4
8 changed files with 49 additions and 42 deletions

4
vm.c
View file

@ -607,7 +607,7 @@ rb_serial_t ruby_vm_global_cvar_state = 1;
static const struct rb_callcache vm_empty_cc = {
.flags = T_IMEMO | (imemo_callcache << FL_USHIFT) | VM_CALLCACHE_UNMARKABLE,
.klass = Qfalse,
.klass = Qundef,
.cme_ = NULL,
.call_ = vm_call_general,
.aux_ = {
@ -617,7 +617,7 @@ static const struct rb_callcache vm_empty_cc = {
static const struct rb_callcache vm_empty_cc_for_super = {
.flags = T_IMEMO | (imemo_callcache << FL_USHIFT) | VM_CALLCACHE_UNMARKABLE,
.klass = Qfalse,
.klass = Qundef,
.cme_ = NULL,
.call_ = vm_call_super_method,
.aux_ = {