Reuse of Set.new at prefixes variables#157
Merged
kou merged 2 commits intoruby:masterfrom Jun 23, 2024
Merged
Conversation
## Why?
Set.new() instances of the prefixes variable can be reused, reducing initialization costs.
## Result
```
RUBYLIB= BUNDLER_ORIG_RUBYLIB= /Users/naitoh/.rbenv/versions/3.3.3/bin/ruby -v -S benchmark-driver /Users/naitoh/ghq/github.com/naitoh/rexml/benchmark/parse.yaml
ruby 3.3.3 (2024-06-12 revision f1c7b6f435) [arm64-darwin22]
Calculating -------------------------------------
before after before(YJIT) after(YJIT)
dom 17.714 17.658 32.898 33.247 i/s - 100.000 times in 5.645176s 5.663160s 3.039707s 3.007755s
sax 25.280 25.281 47.483 49.990 i/s - 100.000 times in 3.955694s 3.955534s 2.106006s 2.000389s
pull 29.048 29.061 59.944 61.498 i/s - 100.000 times in 3.442599s 3.441014s 1.668222s 1.626060s
stream 28.181 28.440 52.340 55.078 i/s - 100.000 times in 3.548546s 3.516169s 1.910599s 1.815599s
Comparison:
dom
after(YJIT): 33.2 i/s
before(YJIT): 32.9 i/s - 1.01x slower
before: 17.7 i/s - 1.88x slower
after: 17.7 i/s - 1.88x slower
sax
after(YJIT): 50.0 i/s
before(YJIT): 47.5 i/s - 1.05x slower
after: 25.3 i/s - 1.98x slower
before: 25.3 i/s - 1.98x slower
pull
after(YJIT): 61.5 i/s
before(YJIT): 59.9 i/s - 1.03x slower
after: 29.1 i/s - 2.12x slower
before: 29.0 i/s - 2.12x slower
stream
after(YJIT): 55.1 i/s
before(YJIT): 52.3 i/s - 1.05x slower
after: 28.4 i/s - 1.94x slower
before: 28.2 i/s - 1.95x slower
```
YJIT=ON : 1.01x - 1.05x faster
YJIT=OFF : 0.99x - 1.00x faster
Member
|
Thanks. |
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.
Why?
Set.new()instances of the prefixes variable can be reused, reducing initialization costs.Result
YJIT=ON : 1.01x - 1.05x faster
YJIT=OFF : 0.99x - 1.00x faster