-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
Replace forwardable with explicit delegation for performance #312
Closed
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'm doing performance profiling and was surprised for these to appear at all in the flamegraph. Here are some numbers: ``` # with forwardable in both rubocop + rubocop-ast $ hyperfine -w 3 -r 20 "bundle exec rubocop Rakefile" Benchmark 1: bundle exec rubocop Rakefile Time (mean ± σ): 1.169 s ± 0.016 s [User: 0.976 s, System: 0.190 s] Range (min … max): 1.138 s … 1.198 s 20 runs # with forwardable only in rubocop-ast $ hyperfine -w 3 -r 20 "bundle exec rubocop Rakefile" Benchmark 1: bundle exec rubocop Rakefile Time (mean ± σ): 1.145 s ± 0.011 s [User: 0.959 s, System: 0.185 s] Range (min … max): 1.131 s … 1.170 s 20 runs # with forwardable in neither $ hyperfine -w 3 -r 20 "bundle exec rubocop Rakefile" Benchmark 1: bundle exec rubocop Rakefile Time (mean ± σ): 1.136 s ± 0.020 s [User: 0.950 s, System: 0.183 s] Range (min … max): 1.098 s … 1.168 s 20 runs ``` Overall ~ 3% faster ------- Full run, also about 3%: ``` # with forwardable in both rubocop + rubocop-ast $ hyperfine -w 3 -r 20 "bundle exec rubocop" Benchmark 1: bundle exec rubocop Time (mean ± σ): 1.704 s ± 0.018 s [User: 1.903 s, System: 1.004 s] Range (min … max): 1.669 s … 1.742 s 20 runs # with forwardable only in rubocop-ast $ hyperfine -w 3 -r 20 "bundle exec rubocop" Benchmark 1: bundle exec rubocop Time (mean ± σ): 1.677 s ± 0.025 s [User: 1.847 s, System: 0.988 s] Range (min … max): 1.640 s … 1.763 s 20 runs # with forwardable in neither $ hyperfine -w 3 -r 20 "bundle exec rubocop" Benchmark 1: bundle exec rubocop Time (mean ± σ): 1.656 s ± 0.020 s [User: 1.817 s, System: 0.984 s] Range (min … max): 1.630 s … 1.700 s 20 runs ```
8 tasks
marcandre
requested changes
Aug 30, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR and the benchmark ❤️
I am not opposed to not using the builtin forwardable
but I believe we could keep the abstraction in place with a custom and minimal variant.
I commented on the rubocop
thread.
Earlopain
added a commit
to Earlopain/rubocop
that referenced
this pull request
Sep 3, 2024
Introduced in rubocop/rubocop-ast#312 Also see rubocop#13175 I performance tested this change and found no significant difference, which makes sense since it's basically the same thing
bbatsov
pushed a commit
to rubocop/rubocop
that referenced
this pull request
Sep 3, 2024
Introduced in rubocop/rubocop-ast#312 Also see #13175 I performance tested this change and found no significant difference, which makes sense since it's basically the same thing
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'm doing performance profiling and was surprised for these to appear at all in the samples. Here are some numbers (3 warmup runs, 20 measured runs, cache used):
Overall ~ 3% faster
Full run, also about 3%:
The impact of changing
rubocop-ast
is not as large as the one inrubocop
but its something nontheless. I think this makes sense and the added code is not that complex.Companion PR for rubocop: rubocop/rubocop#13175
I don't need an immediate release should this get merged. Numbers are not that impressive and its a hard sell for the changelog. I'm fine with waiting for some more substantial change at a later time.