forked from ohler55/oj
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make compaction available for
Oj::Doc
Introduce compaction to `fast.c`, only if `rb_gc_mark_movable` is available. Otherwise, keep a version that supports ruby <2.7. Since `rb_data_object_wrap` and `TypedData_Wrap_Struct` is available in 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 generate 5k more objects (5499 pinned objects total). Hence this is a win, see ohler55#650 for a graphical result. Signed-off-by: Ulysse Buonomo <buonomo.ulysse@gmail.com>
- Loading branch information
Showing
6 changed files
with
58 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,4 +92,3 @@ begin | |
|
||
rescue LoadError | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
module Oj | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters