-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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 slice::swap_unchecked
#88540
add slice::swap_unchecked
#88540
Conversation
r? @kennytm (rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cf9694a
to
bc999ca
Compare
See #71874 |
I think it's worth using this inside slice::reverse. |
triage: @ibraheemdev could you address the above comments? Thanks! |
774b8d3
to
c517a0d
Compare
@bors r+ |
📌 Commit cf12732 has been approved by |
add `slice::swap_unchecked` An unsafe version of `slice::swap` that does not do bounds checking.
@bors rollup=never likely has some perf effects |
☀️ Test successful - checks-actions |
Finished benchmarking commit (1dafe6d): comparison url. Summary: This change led to small relevant regressions 😿 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
maybe revert the implementation of the safe |
@kennytm @ibraheemdev this seems to have landed with more bounds checking than is necessary though I would imagine that the extra checking shouldn't be happening in the compiler since debug assertions are off. While the regressions aren't huge, they are in real world crates and this is likely to effect the perf of many (most?) Rust programs in a negative way. Perhaps we should do the suggestion of reverting the implementation of the safe Also FYI, when it's likely that a perf regression could come out of a change (as was pointed out) it's best to just run a perf run before merging. |
IIRC, I'm also surprised that there's a regression; like you said, I thought the compiler was by default built with debug assertions turned off. Maybe the bounds checks are not the source of the regression? |
Revert implementation of `slice::swap` Due to the perf regressions noticed here, possible due to inlining? rust-lang#88540 (comment) r? `@kennytm`
An unsafe version of
slice::swap
that does not do bounds checking.