Skip to content

Commit 1a6b13d

Browse files
committed
Avoid unnecessary writes to ISEQ during GC
On mark we check whether a callcache has been invalidated and if it has we replace it with the empty callcache, rb_vm_empty_cc(). However we also consider the empty callcache to not be active, and so previously would overwrite it with itself. These additional writes are problematic because they may force Copy-on-Write to occur on the memory page, increasing system memory use.
1 parent be1089c commit 1a6b13d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

iseq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
344344
if (cc_is_active(cds[i].cc, reference_updating)) {
345345
rb_gc_mark_and_move_ptr(&cds[i].cc);
346346
}
347-
else {
347+
else if (cds[i].cc != rb_vm_empty_cc()) {
348348
cds[i].cc = rb_vm_empty_cc();
349349
}
350350
}

0 commit comments

Comments
 (0)