summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2024-06-02 23:39:36 -0700
committerJohn Hawthorn <[email protected]>2024-06-03 11:02:49 -0700
commit9d6b8806a4e0801c260f628e48a21ae94cb3fc91 (patch)
treef87badd0190cc219ebde4a4cf78a022c29d4046d
parent17b89849c6076777ccfd014f191f8c97f81f8cae (diff)
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.
-rw-r--r--iseq.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/iseq.c b/iseq.c
index 9631488411..05d52b61b4 100644
--- a/iseq.c
+++ b/iseq.c
@@ -346,7 +346,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();
}
}