Skip to content

Commit

Permalink
Avoid unnecessary writes to ISEQ during GC
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhawthorn authored and composerinteralia committed Nov 5, 2024
1 parent acdbaa6 commit 8ee5847
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ rb_iseq_mark_and_move(rb_iseq_t *iseq, bool reference_updating)
if (cc_is_active(cds[i].cc, reference_updating)) {
rb_gc_mark_and_move_ptr(&cds[i].cc);
}
else {
else if (cds[i].cc != rb_vm_empty_cc()) {
cds[i].cc = rb_vm_empty_cc();
}
}
Expand Down

0 comments on commit 8ee5847

Please sign in to comment.