-
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
Simplify Vec
using iter::repeat_n
#104596
Conversation
Today it always copies it for *every* appended element, but one of those clones is avoidable.
By using `repeat_n` instead of `ExtendElement`, we can delete a bunch more `unsafe` code from `Vec. All the codegen tests are passing (and I made one stricter to help be sure), so let's see if perf is also happy with it.
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 50b394a with merge 30c97e84bdbff017290f6d12db34df2f225359a8... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (30c97e84bdbff017290f6d12db34df2f225359a8): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
I'm not sure if it's a good idea to remove this. There's untapped optimization potential in the current implementation. E.g. it could use the zero-value check that vec initialization already has and then use |
@the8472 I agree that's a good thing to add, but I don't think it needs the |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 78f2356 with merge d6ba54d913266c13b4ddf2eaf8b1b9b023df4caa... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (d6ba54d913266c13b4ddf2eaf8b1b9b023df4caa): comparison URL. Overall result: ❌ regressions - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis 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.
CyclesResultsThis 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.
|
Curious -- arguably good on cycles, but clearly bad on instructions. I guess I should do this in smaller pieces, if at all. |
Repeating is `TrustedLen`, so we don't need another copy of [the `TrustedLen` specialization for `extend`](https://github.com/rust-lang/rust/blob/c5d82ed7a4ad94a538bb87e5016e7d5ce0bd434b/library/alloc/src/vec/spec_extend.rs#L27). (This is a simpler version of rust-lang#104596, which tried to do too many things at once.)
By using
repeat_n
instead ofExtendElement
, we can delete a bunch moreunsafe
code fromVec
.All the codegen tests are passing (and I made one stricter to help be sure), so let's see if perf is also happy with it.
r? @ghost
Built atop #104435; will leave draft until I can rebase atop that.