Refactor vm->mark_object_ary
to be a linked list of WB protected objects
#10179
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix: #10171
This
st_table
is used to both mark and pin classes defined from the C API. Butvm->mark_object_ary
already does both much more efficiently.Currently a Ruby process starts with 252 rooted classes, which uses
7224B
in anst_table
or2016B
in anRArray
.So a baseline of 5kB saved, but since
mark_object_ary
is preallocated with1024
slots but only use405
of them, it's a net7kB
save.vm->mark_object_ary
is also being refactored.Prior to this changes,
mark_object_ary
was a regularRArray
, but since this allows for references to be moved, it was marked a second time fromrb_vm_mark()
to pin these objects.This has the detrimental effect of marking these references on every minors even though it's a mostly append only list.
But using a custom TypedData we can save from having to mark all the references on minor GC runs.
Addtionally, immediate values are now ignored and not appended to
vm->mark_object_ary
as it's just wasted space.cc @peterzhu2118