diff options
author | John Hawthorn <[email protected]> | 2024-02-11 21:43:38 -0800 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2024-02-20 18:55:00 -0800 |
commit | 1c97abaabae6844c861705fd07f532292dcffa74 () | |
tree | a1d5dbac7eab32f6ffc168f1e556dfac085bc89a /gc.c | |
parent | 2a6917b463fa4065f26aea44802e2e24cc494e4c (diff) |
De-dup identical callinfo objects
Previously every call to vm_ci_new (when the CI was not packable) would result in a different callinfo being returned this meant that every kwarg callsite had its own CI. When calling, different CIs result in different CCs. These CIs and CCs both end up persisted on the T_CLASS inside cc_tbl. So in an eval loop this resulted in a memory of both types of object. This also likely resulted in extra memory used, and extra time searching, in non-eval cases. For simplicity in this commit I always allocate a CI object inside rb_vm_ci_lookup, but ideally we would lazily allocate it only when needed. I hope to do that as a follow up in the future.
-rw-r--r-- | gc.c | 1 |
1 files changed, 1 insertions, 0 deletions
@@ -3745,6 +3745,7 @@ obj_free(rb_objspace_t *objspace, VALUE obj) case imemo_callinfo: { const struct rb_callinfo * ci = ((const struct rb_callinfo *)obj); if (ci->kwarg) { ((struct rb_callinfo_kwarg *)ci->kwarg)->references--; if (ci->kwarg->references == 0) xfree((void *)ci->kwarg); |