Apply "polymorphization at home" to RawVec#126793
Conversation
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Monomorphize RawVec The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times. r? `@ghost`
This comment has been minimized.
This comment has been minimized.
library/alloc/src/raw_vec.rs
Outdated
| // of the code that doesn't depend on `T` as possible is in functions that | ||
| // are non-generic over `T`. | ||
| fn grow_amortized(&mut self, len: usize, additional: usize) -> Result<(), TryReserveError> { | ||
| const { assert!(mem::size_of::<T>() % mem::align_of::<T>() == 0) }; |
There was a problem hiding this comment.
nit: is this checking anything? That's definitionally true for all types, AFAIK...
There was a problem hiding this comment.
🤷 This was in the original code. There's also a wrong comment in current_memory about types where size != stride, such types do not exist in Rust.
There was a problem hiding this comment.
I've deleted all these const assertions. I don't know if that was the right move here? I'm not opposed to adding it by some other means, but it seems a bit silly to have an assertion if it's true by definition.
| } | ||
|
|
||
| struct MonoRawVec<A: Allocator = Global> { | ||
| ptr: Unique<u8>, |
There was a problem hiding this comment.
YMMV: Maybe make yourself an opaque type (like the one in
rust/library/core/src/ptr/metadata.rs
Lines 160 to 166 in 5ced3da
u8-ness of this anywhere?
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (7646794): 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)Results (primary -0.6%, secondary -4.9%)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.2%, secondary -3.2%)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 sizeResults (primary -2.0%, secondary -0.5%)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.
Bootstrap: 694.089s -> 690.601s (-0.50%) |
|
Woah, this looks awesome! Truly a "we have polymorphization at home" moment. |
tests/mir-opt/pre-codegen/vec_deref.vec_deref_to_slice.PreCodegen.after.panic-unwind.mir
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
|
💔 Test failed - checks-actions |
|
@bors try |
This comment has been minimized.
This comment has been minimized.
|
💔 Test failed - checks-actions |
|
@bors try |
|
☀️ Try build successful - checks-actions |
|
After some slow trial-and-error, I think I've fixed the debuginfo tests. @bors r=scottmcm |
|
☀️ Test successful - checks-actions |
|
👀 Test was successful, but fast-forwarding failed: 422 Update is not a fast forward |
|
@bors r=scottmcm |
|
💡 This pull request was already approved, no need to approve it again.
|
|
Finished benchmarking commit (ba33d7b): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression 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)Results (primary -0.5%, secondary 0.6%)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 -1.3%, secondary 0.5%)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 sizeResults (primary -1.6%, secondary -0.3%)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.
Bootstrap: 756.29s -> 754.361s (-0.26%) |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (13f8a57): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression 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)Results (primary -0.8%, secondary 0.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.
CyclesResults (primary -1.1%, secondary -1.2%)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 sizeResults (primary -1.6%, secondary -0.3%)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.
Bootstrap: 755.478s -> 752.51s (-0.39%) |
|
Seconding, but also noting that this seems to have been a good memory usage improvement (probably due to smaller code footprint?) that held up as the week progressed. Good work! |
The idea here is to move all the logic in RawVec into functions with explicit size and alignment parameters. This should eliminate all the fussing about how tweaking RawVec code produces large swings in compile times.
This uncovered rust-lang/rust-clippy#12979, so I've modified the relevant test in a way that tries to preserve the spirit of the test without tripping the ICE.