-
Notifications
You must be signed in to change notification settings - Fork 13.3k
More macro expansion optimizations #95259
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
More macro expansion optimizations #95259
Conversation
Some
|
There likely won't be much change within the rustc-perf benchmarks, but let's check just in case. @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit 19cb13688ffeff3e17f4ce1626620f81c1c74b7d with merge d8f7c9a8b9640de025c4eacb58c71dd15db53b74... |
☀️ Try build successful - checks-actions |
Queued d8f7c9a8b9640de025c4eacb58c71dd15db53b74 with parent 37b55c8, future comparison URL. |
Finished benchmarking commit (d8f7c9a8b9640de025c4eacb58c71dd15db53b74): comparison url. Summary: This benchmark run shows 5 relevant improvements 🎉 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Benchmarking 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 led to changes in compiler perf. @bors rollup=never |
|
@bors r+ |
bors did not respond. |
@bors r+ |
📌 Commit 19cb13688ffeff3e17f4ce1626620f81c1c74b7d has been approved by |
Interesting! I will take a look, I have plans to do more here anyway. |
The `Lrc` is only relevant within `transcribe()`. There, the `Lrc` is helpful for the non-`NtTT` cases, because the entire nonterminal is cloned. But for the `NtTT` cases the inner token tree is cloned (a full clone) and so the `Lrc` is of no help. This commit splits the `NtTT` and non-`NtTT` cases, avoiding the useless `Lrc` in the former case, for the following effect on macro-heavy crates. - It reduces the total number of allocations a lot. - It increases the size of some of the remaining allocations. - It doesn't affect *peak* memory usage, because the larger allocations are short-lived. This overall gives a speed win.
This counters the `NamedMatchVec` size increase from the previous commit, leaving `NamedMatchVec` smaller than before.
Currently it copies a `KleeneOp` and a `Token` out of a `SequenceRepetition`. It's better to store a reference to the `SequenceRepetition`, which is now possible due to rust-lang#95159 having changed the lifetimes.
19cb136
to
fdec26d
Compare
I pushed an update to remove an "njn:" comment that I accidentally left behind. @bors r=petrochenkov |
📌 Commit fdec26d has been approved by |
☀️ Test successful - checks-actions |
Finished benchmarking commit (8a0c550): comparison url. Summary: This benchmark run shows 4 relevant improvements 🎉 but 1 relevant regression 😿 to instruction counts.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
The perf wins clearly outweigh the losses here. @rustbot label: +perf-regression-triaged |
A few nice wins for macro-heavy crates.
r? @petrochenkov