perf: Avoid a heap allocation per basic block in MoveData's location maps - #160245
Conversation
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
perf: Avoid a heap allocation per basic block in MoveData's location maps
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (a4ce053): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf. @bors rollup=never rustc-perf Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.4%, secondary -2.7%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary 0.4%, secondary 0.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 492.09s -> 496.702s (0.94%) |
|
r? @nnethercote |
| impl<T> IndexMut<Location> for LocationMap<T> { | ||
| fn index_mut(&mut self, index: Location) -> &mut Self::Output { | ||
| &mut self.map[index.block][index.statement_index] | ||
| let offset = self.offset(index); |
There was a problem hiding this comment.
unfortunately &mut self.data[self.offset(index)] fails borrowck:
error[E0502]: cannot borrow `*self` as immutable because it is also borrowed as mutable
|
| fn index_mut(&mut self, index: Location) -> &mut Self::Output {
| - let's call the lifetime of this reference `'1`
| &mut self.data[self.offset(index)]
| ---------------^^^^---------------
| | | |
| | | immutable borrow occurs here
| | mutable borrow occurs here
| returning this value requires that `self.data` is borrowed for `'1`
57527a3 to
b146323
Compare
|
Thanks for the quick review! |
|
@bors r+ |
| /// `block_starts[bb]` gives the index in `data` where block `bb`'s entries | ||
| /// start; each block has one entry per statement plus one for its terminator. | ||
| data: Vec<T>, | ||
| block_starts: IndexVec<BasicBlock, usize>, |
There was a problem hiding this comment.
Should we eventually move to use an IndexVec<PointIndex> with a shared DenseLocationMap?
This comment has been minimized.
This comment has been minimized.
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 b6a3d79 (parent) -> c47bb2f (this PR) Test differencesShow 2 test diffs2 doctest diffs were found. These are ignored, as they are noisy. Test dashboardRun cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard c47bb2f39658c00b109693df9611d7238bedf6fa --output-dir test-dashboardAnd then open Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
|
Finished benchmarking commit (c47bb2f): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -4.2%, secondary -1.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -0.8%, secondary -0.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: 491.498s -> 490.834s (-0.14%) |
MoveDataholds twoLocationMaps, and each was anIndexVec<BasicBlock, Vec<T>>that heap-allocated oneVecper basic block. Building the move data for a body allocated a small vector for every block, twice over. Store the entries in one flat buffer indexed by a per-block start offset, so each map is two allocations regardless of block count.