-
Notifications
You must be signed in to change notification settings - Fork 138
Optimize Ref<_, T> methods when T: Sized (#2752) #2758
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
Conversation
Summary of ChangesHello @bmberger, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces targeted optimizations for Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
This pull request introduces an optimization for Sized types in several methods of Ref<_, T>. The logic seems sound, and the addition of benchmarks is a great way to validate the performance impact. My main feedback is regarding significant code duplication across four methods, which could be refactored to improve maintainability. I've provided a suggestion to use a macro to deduplicate this logic.
f68da63 to
08ba7b2
Compare
08ba7b2 to
2fef20b
Compare
2fef20b to
d62f86c
Compare
02dd1cd to
3f7849b
Compare
|
Okay, I've rebased on |
joshlf
left a comment
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.
Please update the commit message with new benchmark numbers, but otherwise LGTM!
3f7849b to
1b91935
Compare
1b91935 to
061dbe3
Compare
b1fc793 to
a2a8a49
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2758 +/- ##
==========================================
+ Coverage 91.89% 92.02% +0.13%
==========================================
Files 20 20
Lines 5773 5870 +97
==========================================
+ Hits 5305 5402 +97
Misses 468 468 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a2a8a49 to
b023d10
Compare
With optimization: test r#ref::benches::bench_deref_mut_sized ... bench: 0.64 ns/iter (+/- 0.25) test r#ref::benches::bench_deref_sized ... bench: 0.54 ns/iter (+/- 0.20) test r#ref::benches::bench_from_bytes_sized ... bench: 5.71 ns/iter (+/- 1.59) test r#ref::benches::bench_into_mut_sized ... bench: 0.66 ns/iter (+/- 0.05) test r#ref::benches::bench_into_ref_sized ... bench: 0.88 ns/iter (+/- 0.08) Without optimization: test r#ref::benches::bench_deref_mut_sized ... bench: 0.74 ns/iter (+/- 0.09) test r#ref::benches::bench_deref_sized ... bench: 0.69 ns/iter (+/- 0.10) test r#ref::benches::bench_from_bytes_sized ... bench: 5.09 ns/iter (+/- 0.42) test r#ref::benches::bench_into_mut_sized ... bench: 0.68 ns/iter (+/- 0.08) test r#ref::benches::bench_into_ref_sized ... bench: 0.88 ns/iter (+/- 0.01) Closes google#2752 Co-authored-by: Joshua Liebow-Feeser <joshlf@google.com>
b023d10 to
ab598ae
Compare
With optimization:
test r#ref::benches::bench_deref_mut_sized ... bench: 0.64 ns/iter (+/- 0.25)
test r#ref::benches::bench_deref_sized ... bench: 0.54 ns/iter (+/- 0.20)
test r#ref::benches::bench_from_bytes_sized ... bench: 5.71 ns/iter (+/- 1.59)
test r#ref::benches::bench_into_mut_sized ... bench: 0.66 ns/iter (+/- 0.05)
test r#ref::benches::bench_into_ref_sized ... bench: 0.88 ns/iter (+/- 0.08)
Without optimization:
test r#ref::benches::bench_deref_mut_sized ... bench: 0.74 ns/iter (+/- 0.09)
test r#ref::benches::bench_deref_sized ... bench: 0.69 ns/iter (+/- 0.10)
test r#ref::benches::bench_from_bytes_sized ... bench: 5.09 ns/iter (+/- 0.42)
test r#ref::benches::bench_into_mut_sized ... bench: 0.68 ns/iter (+/- 0.08)
test r#ref::benches::bench_into_ref_sized ... bench: 0.88 ns/iter (+/- 0.01)
Closes #2752