Skip to content

Conversation

joboet
Copy link
Member

@joboet joboet commented Mar 22, 2025

...by adding an optimized implementation of try_fold and fold as well as replacing some unnecessary mem::replace calls with MaybeUninit helper methods.

...by adding an optimized implementation of `try_fold` and `fold` as well as replacing some unnecessary `mem::replace` calls with `MaybeUninit` helper methods.
@rustbot
Copy link
Collaborator

rustbot commented Mar 22, 2025

r? @thomcc

rustbot has assigned @thomcc.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Mar 22, 2025
@thomcc
Copy link
Member

thomcc commented Mar 22, 2025

Looks great, thanks.

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Mar 22, 2025

📌 Commit 51d51c8 has been approved by thomcc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 22, 2025
@@ -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());
Copy link
Member

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.

Copy link
Member Author

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.

@bors
Copy link
Collaborator

bors commented Mar 23, 2025

⌛ Testing commit 51d51c8 with merge f08d5c0...

@bors
Copy link
Collaborator

bors commented Mar 23, 2025

☀️ Test successful - checks-actions
Approved by: thomcc
Pushing f08d5c0 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 23, 2025
@bors bors merged commit f08d5c0 into rust-lang:master Mar 23, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Mar 23, 2025
Copy link
Contributor

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 differences

Show 8 test diffs

Additionally, 8 doctest diffs were found. These are ignored, as they are noisy.

Job group index

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f08d5c0): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This 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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

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.

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.1% [3.1%, 3.1%] 1

Cycles

Results (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.

mean range count
Regressions ❌
(primary)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 774.407s -> 774.928s (0.07%)
Artifact size: 365.55 MiB -> 365.54 MiB (-0.00%)

github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this pull request Apr 2, 2025
core: optimize `RepeatN`

...by adding an optimized implementation of `try_fold` and `fold` as well as replacing some unnecessary `mem::replace` calls with `MaybeUninit` helper methods.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants