-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Shrink thir::Pat
#101139
Shrink thir::Pat
#101139
Conversation
I'm not expecting big changes to perf, but let's check: @bors try @rust-timer queue |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit e61b4ab3d67e1fa18752a26fe276f84e03b307bc with merge 324c6fac56d966385f3ab26afe625faa0a58a17f... |
☀️ Try build successful - checks-actions |
Queued 324c6fac56d966385f3ab26afe625faa0a58a17f with parent ce36e88, future comparison URL. |
Finished benchmarking commit (324c6fac56d966385f3ab26afe625faa0a58a17f): comparison URL. Overall result: ❌ regressions - no 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. @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)ResultsThis 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.
CyclesResultsThis 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.
Footnotes |
Silly question: why use |
The first commit log explains this:
|
📌 Commit e61b4ab3d67e1fa18752a26fe276f84e03b307bc has been approved by It is now in the queue for this repository. |
Not a silly question, a very relevant one :) Before I did this PR I tried to introduce I always try to structure my commits carefully, and I often write "best reviewed one commit at a time", but I failed to do so on this PR. |
☔ The latest upstream changes (presumably #101239) made this pull request unmergeable. Please resolve the merge conflicts. |
`thir::Pat::kind` is a `Box<PatKind>`, which doesn't follow the usual pattern in AST/HIR/THIR which is that the "kind" enum for a node is stored inline within the parent struct. This commit makes the `PatKind` directly inline within the `Pat`. This requires using `Box<Pat>` in all the types that hold a `Pat. Ideally, `Pat` would be stored in `Thir` like `Expr` and `Stmt` and referred to with a `PatId` rather than `Box<Pat>`. But this is hard to do because lots of `Pat`s get created after the destruction of the `Cx` that does normal THIR building. But this does get us a step closer to `PatId`, because all the `Box<Pat>` occurrences would be replaced with `PatId` if `PatId` ever happened. At 128 bytes, `Pat` is large. Subsequent commits will shrink it.
`Builder::expr_into_pattern` has a single call site. Currently the `pattern` argument at the call site is always cloned. This commit changes things so that we instead do a clone within `expr_into_pattern`, but only if the pattern has the `PatKind::AscribeUserType` kind, and we only clone the annotation within the pattern instead of the entire pattern.
Because it's the biggest variant. Also, make `PatRange` non-`Copy`, because it's 104 bytes, which is pretty big.
This shrinks `Ascription`, which shrinks `PatKind::AscribeUserType`, which shrinks `Pat`.
To shrink it a little more.
e61b4ab
to
43a0268
Compare
I rebased to fix the conflicts. @bors r=cjgillot |
☀️ Test successful - checks-actions |
Finished benchmarking commit (0421444): comparison URL. Overall result: ✅ improvements - no action needed@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)ResultsThis 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.
CyclesResultsThis 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.
Footnotes |
Unfortunately not, because of this sequence:
|
r? @cjgillot