-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add RB_UNLIKELY hint for tracing log #782
Merged
Merged
Conversation
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
I think that `Yes == pi->options.trace` will be false in most cases. If the compiler supports it, the UNLIKELY hint might speed up the conditional branching slightly. − | before | after | result -- | -- | -- | -- Oj.load | 374.821k |383.001k | 1.022x ### Environment - Linux - Manjaro Linux x86_64 - Kernel: 5.18.0-1-rt11-MANJARO - AMD Ryzen 7 5700G - gcc version 12.1.0 - Ruby 3.1.2 ### Before ``` Warming up -------------------------------------- Oj.load 37.784k i/100ms Calculating ------------------------------------- Oj.load 374.821k (± 0.5%) i/s - 7.519M in 20.060807s ``` ### After ``` Warming up -------------------------------------- Oj.load 38.599k i/100ms Calculating ------------------------------------- Oj.load 383.001k (± 0.5%) i/s - 7.681M in 20.055707s ``` ### Test code ```ruby require 'benchmark/ips' require 'oj' json =<<-EOF { "$id": "https://example.com/person.schema.json", "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "Person", "type": "object", "properties": { "firstName": { "type": "string", "description": "The person's first name." }, "lastName": { "type": "string", "description": "The person's last name." }, "age": { "description": "Age in years which must be equal to or greater than zero.", "type": "integer", "minimum": 0 } } } EOF Benchmark.ips do |x| x.warmup = 10 x.time = 20 x.report('Oj.load') { Oj.load(json) } end ```
ohler55
approved these changes
Jul 6, 2022
Watson1978
added a commit
to Watson1978/oj
that referenced
this pull request
Jul 24, 2022
If the compiler supports it, the UNLIKELY hint might speed up the conditional branching slightly. Ref. ohler55#782 − | before | after | result -- | -- | -- | -- Oj.load | 11.754M | 11.775M | - ### Environment - Linux - Manjaro Linux x86_64 - Kernel: 5.18.12-3-MANJARO - AMD Ryzen 7 5700G - gcc version 12.1.0 - Ruby 3.1.2 ### Before ``` Warming up -------------------------------------- Oj.dump 1.166M i/100ms Calculating ------------------------------------- Oj.dump 11.754M (± 0.2%) i/s - 177.254M in 15.080998s ``` ### After ``` Warming up -------------------------------------- Oj.dump 1.184M i/100ms Calculating ------------------------------------- Oj.dump 11.775M (± 0.2%) i/s - 177.612M in 15.084141s ``` ### Test code ```ruby require 'benchmark/ips' require 'oj' data = 42 Benchmark.ips do |x| x.warmup = 5 x.time = 15 x.report('Oj.dump') do |times| i = 0 while i < times Oj.dump(data) i += 1 end end end ```
Watson1978
added a commit
to Watson1978/oj
that referenced
this pull request
Jul 24, 2022
If the compiler supports it, the UNLIKELY hint might speed up the conditional branching slightly. Ref. ohler55#782 − | before | after | result -- | -- | -- | -- Oj.dump | 11.754M | 11.775M | - ### Environment - Linux - Manjaro Linux x86_64 - Kernel: 5.18.12-3-MANJARO - AMD Ryzen 7 5700G - gcc version 12.1.0 - Ruby 3.1.2 ### Before ``` Warming up -------------------------------------- Oj.dump 1.166M i/100ms Calculating ------------------------------------- Oj.dump 11.754M (± 0.2%) i/s - 177.254M in 15.080998s ``` ### After ``` Warming up -------------------------------------- Oj.dump 1.184M i/100ms Calculating ------------------------------------- Oj.dump 11.775M (± 0.2%) i/s - 177.612M in 15.084141s ``` ### Test code ```ruby require 'benchmark/ips' require 'oj' data = 42 Benchmark.ips do |x| x.warmup = 5 x.time = 15 x.report('Oj.dump') do |times| i = 0 while i < times Oj.dump(data) i += 1 end end end ```
ohler55
pushed a commit
that referenced
this pull request
Jul 24, 2022
If the compiler supports it, the UNLIKELY hint might speed up the conditional branching slightly. Ref. #782 − | before | after | result -- | -- | -- | -- Oj.dump | 11.754M | 11.775M | - ### Environment - Linux - Manjaro Linux x86_64 - Kernel: 5.18.12-3-MANJARO - AMD Ryzen 7 5700G - gcc version 12.1.0 - Ruby 3.1.2 ### Before ``` Warming up -------------------------------------- Oj.dump 1.166M i/100ms Calculating ------------------------------------- Oj.dump 11.754M (± 0.2%) i/s - 177.254M in 15.080998s ``` ### After ``` Warming up -------------------------------------- Oj.dump 1.184M i/100ms Calculating ------------------------------------- Oj.dump 11.775M (± 0.2%) i/s - 177.612M in 15.084141s ``` ### Test code ```ruby require 'benchmark/ips' require 'oj' data = 42 Benchmark.ips do |x| x.warmup = 5 x.time = 15 x.report('Oj.dump') do |times| i = 0 while i < times Oj.dump(data) i += 1 end end end ```
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.
I think that
Yes == pi->options.trace
will be false in most cases.If the compiler supports it, the UNLIKELY hint might speed up the conditional branching slightly.
Environment
Before
After
Test code