Move DepKind and query TLS to rustc_query_system#86038
Move DepKind and query TLS to rustc_query_system#86038cjgillot wants to merge 5 commits intorust-lang:masterfrom
Conversation
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
|
⌛ Trying commit 84a156cb46350ea4ca35884c4a910b62343f0677 with merge b1ce53c0cc21a9301621cb4076f77bf3ec601d7b... |
This comment has been minimized.
This comment has been minimized.
|
☀️ Try build successful - checks-actions |
|
Queued b1ce53c0cc21a9301621cb4076f77bf3ec601d7b with parent 9104c89, future comparison URL. |
|
Finished benchmarking try commit (b1ce53c0cc21a9301621cb4076f77bf3ec601d7b): 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 |
|
31% diesel-doc regression is red herring: #85993 (comment) |
There was a problem hiding this comment.
Could these Options be removed and instead clear the ImplicitContext in the tls when they would be None?
There was a problem hiding this comment.
I don't think so. The implicitctxt is still required to detect cycles and to print query stack even when the dependencies are ignored.
There was a problem hiding this comment.
And the other fields? At least one can be made non-optional, right? I don't see what the difference between no implicitctxt and an empty implicitctxt would be.
There was a problem hiding this comment.
Indeed, query should not need to be an option.
a5bfc56 to
a91b82e
Compare
|
Ping from triage: |
|
triage: Is this PR experimental? If so, you can replace |
|
☀️ Try build successful - checks-actions |
|
Queued 38e911f90695efec7806bf6f6c1dccc01a05c130 with parent 4b043fa, future comparison URL. |
|
Finished benchmarking commit (38e911f90695efec7806bf6f6c1dccc01a05c130): comparison url. Summary: This benchmark run shows 98 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 |
Mark-Simulacrum
left a comment
There was a problem hiding this comment.
Would be nice to squash the commits in, and modulo some nits this seems good to me. I think in a fully ideal world the query system would be less tightly coupled to the particular queries, but in practice we both care about performance and the abstractions actually hurt us more than help, I suspect.
There was a problem hiding this comment.
nit: "current" TyCtxt seems a little misleading -- we really expect just one, right? I wonder if there's some slight alternate framing that would work well here.
FWIW, I think the thread_local nature here may be important for things like unit tests and such which want to spin up their own TyCtxt's -- I'm not sure we should drop the TLS variable. At the very least, we should make sure we don't have UB or so if there's conflicts.
There was a problem hiding this comment.
There may be multiple TyCtxt in the same process if you use rustc_driver on multiple threads.
There was a problem hiding this comment.
Minor nit: Maybe TLV should be an AtomicPtr? I'm not sure if that causes us lifetime troubles.
There is only one GlobalCtxt ever.
|
I finally got back to this PR. In this new version, I stop moving the macros to rustc_query_system, and side with @Zoxc's suggestion to make The global pointer to @bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
|
⌛ Trying commit 4387490 with merge 0794d7f4f502d8a0e9a4a71f7669e4adda756b81... |
|
☀️ Try build successful - checks-actions |
|
Queued 0794d7f4f502d8a0e9a4a71f7669e4adda756b81 with parent febce1f, future comparison URL. |
|
Finished benchmarking commit (0794d7f4f502d8a0e9a4a71f7669e4adda756b81): comparison url. Summary:
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 may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Footnotes |
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
|
⌛ Trying commit 8b8c12e with merge 8227b19194e5b9a2926d15786b99e6cc9f73389f... |
|
☀️ Try build successful - checks-actions |
|
Queued 8227b19194e5b9a2926d15786b99e6cc9f73389f with parent 878c783, future comparison URL. |
|
Finished benchmarking commit (8227b19194e5b9a2926d15786b99e6cc9f73389f): comparison url. Summary:
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 may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Footnotes |
| /// query. It is updated when | ||
| /// executing a new query. | ||
| #[derive(Clone, Default)] | ||
| struct ImplicitCtxt<'a> { |
There was a problem hiding this comment.
You should keep the tcx field as a *const (). That lets you move more of the tls module intact and the parallel compiler doesn't regress. with_opt can convert it back in rustc_middle.
You'll want to add an assertion about GlobalCtxt being Sync too, since the type is now erased from ImplicitCtxt.
| // Extend the lifetime of the GlobalCtxt so the new thread can know of it. | ||
| // The current thread will not free it, it is deadlocked. | ||
| let tcx: &'static GlobalCtxt<'static> = | ||
| tls::with(|tcx| &*(*tcx as *const GlobalCtxt<'_>).cast()); |
There was a problem hiding this comment.
This is incorrect since it's only set on one of Rayon's threads. The deadlock handler can be called on any thread. The current state of things is also broken to be fair.
We can not use the Rayon "Task Local Value" either, since the deadlock handler can also be called from a thread with no rustc task is running. My solution to this was to point all threads to a lock which holds the GlobalCtxt when available. It was reverted in #74969.
r? @ghost