Make compaction available for Oj::Doc
#653
Merged
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.
Introduce compaction to
fast.c
, only ifrb_gc_mark_movable
isavailable. Otherwise, keep a version that supports ruby <2.7.
Since
rb_data_object_wrap
andTypedData_Wrap_Struct
is availablein every supported versions (eg >=2.4.10), I've also removed support
for earlier versions.
Result for compaction is great. I've tested it by allocating and
removing arbitrary sized json. For a count of 70 pages, we can see
that we used to need 68 pages after compaction,and now 61 pages. Of
course this test include also lots of noise, but if we count pinned
objects (objects that are marked in C extension as uncollectible),
we can see that for a benchmark with no allocations, we have the
same amount as a benchmark with this commit with thousands of allocations
(499 pinned objects total), and before this,
Oj::Doc
used to generate5k more objects (5499 pinned objects total).
Hence this is a win.
Here's the result of my tests after a
GC.compact
(reddots are pinned objects):see #650 for scripts that generated these results.
Signed-off-by: Ulysse Buonomo buonomo.ulysse@gmail.com