Repository navigation
Keep hot Copy locals out of memory when only a panic path borrows them. - #165362
stephenduong1004 wants to merge 1 commit into
Conversation
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @khyperia rustbot has assigned @khyperia. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@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.
Keep hot Copy locals out of memory when only a panic path borrows them.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (8e92508): 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 -3.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -2.2%, secondary -2.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (secondary 0.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 483.826s -> 485.567s (0.36%) |
|
I'm very much not knowledgeable about mir opts, so, reassigning (I think mir-opt is the right group, lmk if I should have rolled r? mir-opt |
Add a MIR pass
PrepareColdBlocksthat keeps hotCopylocals in registers when they are only borrowed on cold panic paths (likepanic!("{x}")orassert!(c, "{x}")).Currently, borrowing
&xinside a formatting panic forcesnon_ssa_localsto allocate a stack slot forxacross the entire function, spillingxon the hot path. This pass fixes this by copyingxinto a fresh temporary and borrowing©right before a cold&xinstead.AI Usage Disclosure: Used an LLM to generate the initial prototype (#164821) and help draft tests. I implemented this split change myself based on the prototype and design feedback, and reviewed and verified all code and test outputs.