-
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
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
@@ -462,85 +657,26 @@ impl<T, A: Allocator> RawVec<T, A> { | |||
// 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: is this checking anything? That's definitionally true for all types, AFAIK...
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.
🤷 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YMMV: Maybe make yourself an opaque type (like the one in
rust/library/core/src/ptr/metadata.rs
Lines 160 to 166 in 5ced3da
extern "C" { | |
/// Opaque type for accessing vtables. | |
/// | |
/// Private implementation detail of `DynMetadata::size_of` etc. | |
/// There is conceptually not actually any Abstract Machine memory behind this pointer. | |
type VTable; | |
} |
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.
Apply "polymorphization at home" to 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. 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. try-job: x86_64-msvc
☀️ 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! |
…try> Enable Alignment::new_unchecked precondition check Similar to what happened with rust-lang#126556, I think this has become palatable since rust-lang#126793. r? `@ghost`
Apply "polymorphization at home" to 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. 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.
…orkingjubilee Enable Alignment::new_unchecked precondition check Similar to what happened with rust-lang#126556, I think this has become palatable since rust-lang#126793.
…orkingjubilee Enable Alignment::new_unchecked precondition check Similar to what happened with rust-lang#126556, I think this has become palatable since rust-lang#126793.
…ilee Enable Alignment::new_unchecked precondition check Similar to what happened with rust-lang/rust#126556, I think this has become palatable since rust-lang/rust#126793.
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.