-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Name the captured upvars for closures/generators in debuginfo #85020
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
Conversation
2f7b6b7
to
7a0bd3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I left a few comments.
I haven't split closures from I have addressed other comments. Besides, now upvar names are stored in |
Looks good, thanks. Building a new symbol for every capture in mir-build could impact perf, so @bors try |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit fc900b3a86b03476941f4a4b81ab4bfd7000a62b with merge 572ac0ed693592bcc032c44e9272d9dd52db6385... |
☀️ Try build successful - checks-actions |
Queued 572ac0ed693592bcc032c44e9272d9dd52db6385 with parent 607d6b0, future comparison URL. |
Finished benchmarking try commit (572ac0ed693592bcc032c44e9272d9dd52db6385): comparison url. Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up. @bors rollup=never |
A couple of incremental configurations regressed. I'd be willing to land the change with this if we had no clear path to improving the results, but I suspect that making @lrh2000 Would you be able to make |
The code comments I just left should also have a significant impact. EDIT: I'm wondering if we should try those before adding the complexity of a new query, which can also have some negative effects on perf. |
Thanks for your review. Unfortunately, I've got a very busy June, so I do not have time to address the comments before early July. But once I have some free time, I am willing to address them. Sorry for the delay. (And if you want to push some new commits, feel free to do that.) |
Previously, debuggers print closures as something like ``` y::main::closure-0 (0x7fffffffdd34) ``` The pointer actually references to an upvar. It is not very obvious, especially for beginners. It's because upvars don't have names before, as they are packed into a tuple. This commit names the upvars, so we can expect to see something like ``` y::main::closure-0 {_captured_ref__b: 0x[...]} ```
- Closures in external crates may get compiled in because of monomorphization. We should store names of captured variables in `optimized_mir`, so that they are written into the metadata file and we can use them to generate debuginfo. - If there are breakpoints inside closures, the names of captured variables stored in `optimized_mir` can be used to print them. Now the name is more precise when disjoint fields are captured.
@rustbot ready |
@bors try |
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
⌛ Trying commit cf5eda1 with merge f262e7955412a89f47cbb17eb9b2d1332e30a8fa... |
☀️ Try build successful - checks-actions |
Queued f262e7955412a89f47cbb17eb9b2d1332e30a8fa with parent 5ad7389, future comparison URL. |
Not sure what happened. |
This comment has been minimized.
This comment has been minimized.
@rust-timer build f262e7955412a89f47cbb17eb9b2d1332e30a8fa |
Queued f262e7955412a89f47cbb17eb9b2d1332e30a8fa with parent 5ad7389, future comparison URL. |
Code looks good, just awaiting perf results! |
Finished benchmarking try commit (f262e7955412a89f47cbb17eb9b2d1332e30a8fa): comparison url. Summary: This change led to significant mixed results 🤷 in compiler performance.
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. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @bors rollup=never |
So adding the query did improve things quite a bit overall, though not by much on the biggest regression. I'm a little surprised and concerned about why that one benchmark regresses so much, but debuginfo can be huge so maybe it's not that surprising. And there are many more (small) improvements than regressions now. This does improve debuginfo significantly so I'd say the regression is probably justified. @rustbot label: +perf-regression-triaged Thanks for your work on this! |
📌 Commit cf5eda1 has been approved by |
☀️ Test successful - checks-actions |
Previously, debuggers print closures as something like
The pointer actually references to an upvar. It is not very obvious, especially for beginners.
It's because upvars don't have names before, as they are packed into a tuple. This PR names the upvars, so we can expect to see something like
r? @tmandry
Discussed at #84752 (comment) .