Inline GC fastpath in ZJIT for newhash instruction - #17717
Merged
eightbitraptor merged 8 commits intoJul 8, 2026
Conversation
tavianator
reviewed
Jul 7, 2026
eightbitraptor
force-pushed
the
mvh-zjit-inline-fast-path
branch
from
July 7, 2026 20:28
f7e29d9 to
e1fdc71
Compare
tekknolagi
reviewed
Jul 7, 2026
tekknolagi
reviewed
Jul 8, 2026
tekknolagi
reviewed
Jul 8, 2026
tekknolagi
reviewed
Jul 8, 2026
XrXr
reviewed
Jul 8, 2026
This extends the ZJIT GC fast path to the newhash instruction for empty
hashes.
This was verified in a stripped down benchmarking environment, using the
following micro-benchmark in ruby-bench:
```
def run(max)
i = 0
while i < max
h = {}
i += 1
end
end
require_relative '../harness/loader.rb'
run_benchmark(50) do
50.times do
run(500_000)
end
end
```
This patch resulted in a ~30% speedup.
```
master: ruby 4.1.0dev (2026-07-07T14:04:07Z master c51b159) +ZJIT +PRISM [x86_64-linux]
experiment: ruby 4.1.0dev (2026-07-07T19:27:04Z mvh-zjit-inline-fa.. 60730f1) +ZJIT +PRISM [x86_64-linux]
----- ------------ --------------- ------------------ -----------------
bench master (ms) experiment (ms) experiment 1st itr master/experiment
hash 682.3 ± 0.7% 518.0 ± 1.0% 1.082 1.317
----- ------------ --------------- ------------------ -----------------
Legend:
- experiment 1st itr: ratio of master/experiment time for the first benchmarking iteration.
- master/experiment: ratio of master/experiment time. Higher is better for experiment. Above 1 represents a speedup.
```
Co-authored-by: Tavian Barnes <[email protected]>
eightbitraptor
force-pushed
the
mvh-zjit-inline-fast-path
branch
from
July 8, 2026 18:49
a6a2d5c to
d9193cb
Compare
XrXr
approved these changes
Jul 8, 2026
XrXr
left a comment
Member
There was a problem hiding this comment.
LGTM minus CI failure and one comment
eightbitraptor
force-pushed
the
mvh-zjit-inline-fast-path
branch
2 times, most recently
from
July 8, 2026 21:13
f931930 to
36c974b
Compare
eightbitraptor
force-pushed
the
mvh-zjit-inline-fast-path
branch
from
July 8, 2026 21:25
36c974b to
0ad878a
Compare
eightbitraptor
enabled auto-merge (rebase)
July 8, 2026 22:19
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This extends the ZJIT GC fast path to the newhash instruction for empty hashes.
This was verified in a stripped down benchmarking environment, using the following micro-benchmark in ruby-bench:
This patch resulted in a ~30% speedup.