-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Don't monomorphize ty::tls closures in rustc_query_impl #106311
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 473aea57e876dd638c63d3f4b13aa716ef020b74 with merge c082b356fe23b3b62ac02296de4de5d03b136702... |
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (c082b356fe23b3b62ac02296de4de5d03b136702): comparison URL. Overall result: ❌✅ regressions and improvements - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @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.
CyclesThis benchmark run did not return any relevant results for this metric. |
7154a80
to
cf5ed23
Compare
c934b1f
to
6e28ff1
Compare
r? @jyn514 |
the perf regression is probably noise, these benches have been really noise recently |
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.
This seems broadly good to me (7%!!) but I would like to get another set of eyes on the unsafe code. @cjgillot do the changes to rustc_query_impl::plumbing
look right to you?
/// Replaces the current context with `context`. Returns a drop guard that resets the context when it's dropped. | ||
/// | ||
/// # Safety | ||
/// The caller has to ensure that the drop guard is actually run before the lifetime of `context` ends. | ||
#[inline] | ||
pub unsafe fn unsafe_set_scoped_context<'a, 'tcx>( | ||
context: &'a ImplicitCtxt<'a, 'tcx>, | ||
) -> impl Sized { |
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.
Can we make this API safe by returning impl 'a + Sized
, then returning (PhantomData, reset)
?
Actually, that might allow us to make unsafe_get_context
safe too:
type ResetTlvOnDrop = impl Sized;
pub struct ImplicitCtxtToken<'a, 'tcx>(PhantomData<&'a (), &'tcx ()>, ResetTlvOnDrop);
pub fn unsafe_set_scoped_context<'a, 'tcx>(
context: &'a ImplicitCtxt<'a, 'tcx>,
) -> ImplicitCtxtToken<'a, 'tcx> { /* ... */ }
pub fn unsafe_get_context<'a, 'tcx>(token: ImplicitCtxtToken<'a, 'tcx>) -> &'a ImplicitCtxt<'a, 'tcx> { /* ... */ }
Oh, I guess we hit the original reason we're using thread-locals, though, we can't pass the token through the query :/ that's very unfortunate
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.
you could store the token in tls
Yeah, this style of API cannot be made safe given our restrictions. There's a reason why we used closures before :D
It might also make sense to have |
|
⌛ Trying commit 254b7bf with merge a9ebee671300e96fc90fbf5158c16d20a84d61f8... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (a9ebee671300e96fc90fbf5158c16d20a84d61f8): comparison URL. Overall result: ❌ regressions - 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. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @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.
|
Looks like inline(always) lost the perf improvement. So #106311 (comment) is probably the best option here; it has a ~.3% regression on most crates, but speeds up bootstrap times by 7% for query_impl. |
That probably needs to be re-evaluated post #108375. Did you intend to only measure the |
That was @cjgillot's suggestion in #106311 (comment).
Ok, I reverted to the version that only makes the closures non-generic. @bors try |
⌛ Testing commit 5827f79 with merge b9e3d8ff923e24da3ae6734611a88c0ae1531cbb... |
💔 Test failed - checks-actions |
??? @bors try |
⌛ Trying commit 5827f79 with merge 4b296010e62183c6912c1a476363b71ed548976a... |
☀️ Try build successful - checks-actions |
The job Click to see the possible cause of the failure (guessed by this bot)
|
I'm not planning to follow up on this. The query system is changing quite rapidly lately and I don't have time to follow up on these PRs in a reasonable time before they get outdated by other changes. |
alternative to #106270; closes #106270. helps with #65031
Best reviewed commit by commit.
r? @ghost