-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
core: optimize RepeatN
#138833
core: optimize RepeatN
#138833
Conversation
...by adding an optimized implementation of `try_fold` and `fold` as well as replacing some unnecessary `mem::replace` calls with `MaybeUninit` helper methods.
Looks great, thanks. @bors r+ rollup=never |
@@ -95,10 +96,10 @@ impl<A> RepeatN<A> { | |||
fn take_element(&mut self) -> Option<A> { | |||
if self.count > 0 { | |||
self.count = 0; | |||
let element = mem::replace(&mut self.element, MaybeUninit::uninit()); |
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.
curiosity: were you seeing this be a codegen issue? I would guess this was done intentionally to "overwrite" the value with undef
so that Miri could catch any further typed use of it. And overwrite-with-undef optimizes out in LLVM, normally.
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.
Ah, that's why it was written this way... I just saw some strange code and wanted to make it more idiomatic. I can go back to the old version and just keep the fold
part, if you think there's merit in keeping this.
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 756bff9 (parent) -> f08d5c0 (this PR) Test differencesShow 8 test diffsAdditionally, 8 doctest diffs were found. These are ignored, as they are noisy. Job group index |
Finished benchmarking commit (f08d5c0): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary 3.1%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (primary 2.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 774.407s -> 774.928s (0.07%) |
...by adding an optimized implementation of
try_fold
andfold
as well as replacing some unnecessarymem::replace
calls withMaybeUninit
helper methods.