Rework MIR inlining costs by scottmcm · Pull Request #123179 · rust-lang/rust (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
rustbot added S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
bors added a commit to rust-lang-ci/rust that referenced this pull request
…
Rework MIR inlining costs
A bunch of the current costs are surprising, probably accidentally from from not writing out the matches in full. For example, a runtime-length memcpy was treated as the same cost as an Unreachable.
This reworks things around two main ideas:
- Give everything a baseline cost, because even "free" things do take effort in the compiler (CPU & RAM) to MIR inline, and they're easy to calculate
- Then just penalize those things that are materially more than the baseline, like how
[foo; 123]is far more work thanBinOp::AddUncheckedin anRvalue
By including costs for locals and vardebuginfo this makes some things overall more expensive, but because it also greatly reduces the cost for simple things like local variable addition, other things also become less expensive overall.
r? ghost
scottmcm marked this pull request as ready for review
This was referenced
Mar 29, 2024
A bunch of the current costs are surprising, probably accidentally from from not writing out the matches in full. For example, a runtime-length memcpy was treated as the same cost as an Unreachable.
This reworks things around two main ideas:
- Give everything a baseline cost, because even "free" things do take effort to MIR inline, and that's easy to calculate
- Then just penalize those things that are materially more than the baseline, like how
[foo; 123]is far more work thanBinOp::AddUncheckedin anRvalue
By including costs for locals and vardebuginfo this makes some things overall more expensive, but because it also greatly reduces the cost for simple things like local variable addition, other things also become less expensive overall.
bors added a commit to rust-lang-ci/rust that referenced this pull request
…
Rework MIR inlining costs
A bunch of the current costs are surprising, probably accidentally from from not writing out the matches in full. For example, a runtime-length memcpy was treated as the same cost as an Unreachable.
This reworks things around two main ideas:
- Give everything a baseline cost, because even "free" things do take effort in the compiler (CPU & RAM) to MIR inline, and they're easy to calculate
- Then just penalize those things that are materially more than the baseline, like how
[foo; 123]is far more work thanBinOp::AddUncheckedin anRvalue
By including costs for locals and vardebuginfo this makes some things overall more expensive, but because it also greatly reduces the cost for simple things like local variable addition, other things also become less expensive overall.
r? ghost
rustbot added S-waiting-on-author
Status: This is awaiting some action (such as code changes or more information) from the author.
and removed S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels