-
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
perform less decoding if it has the same syntax context #129827
base: master
Are you sure you want to change the base?
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
perform less decoding if it has the same syntax context Following this [comment](rust-lang#127279 (comment)) r? `@petrochenkov`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (73a955e): 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)Results (primary 0.6%, secondary 0.6%)This 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.
CyclesResults (primary -0.1%, secondary 0.2%)This 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.
Binary sizeResults (primary 0.4%, secondary 0.6%)This 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.
Bootstrap: 789.576s -> 791.168s (0.20%) |
772fe96
to
6fcc18a
Compare
@rustbot ready |
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
perform less decoding if it has the same syntax context Following this [comment](rust-lang#127279 (comment)) r? `@petrochenkov`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (8ec48d7): 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)Results (primary -1.4%, secondary -0.8%)This 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.
CyclesResults (primary 6.0%)This 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.
Binary sizeResults (primary -0.5%, secondary -0.7%)This 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.
Bootstrap: 756.954s -> 756.846s (-0.01%) |
{ | ||
ctxt_data = old.clone(); | ||
} | ||
(cache, hygiene_data.syntax_context_data[cache.0 as usize].clone()) |
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.
Or maybe this cache is not necessary because we can compute it immediately🤔
|
||
// Overwrite the dummy data with our decoded SyntaxContextData | ||
HygieneData::with(|hygiene_data| { | ||
if let Some(old) = hygiene_data.syntax_context_data.get(raw_id as usize) |
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.
I'm rereading the code around here carefully and have just noticed that #127279 uses raw_id
to index into hygiene_data.syntax_context_data
.
But that doesn't make any sense!
hygiene_data.syntax_context_data
is indexed by decoded SyntaxContext
s.
remapped_ctxts
s are indexed by raw_id
.
I guess the raw and decoded values can coincide if they are from the local crate during incremental compilation, and things didn't change too much between two compilations, but that's pure luck.
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.
Also, the idea behind #127279 was probably incorrect after all.
If two syntax contexts have matching (parent, outer_expn_id, outer_transparency)
tuples, they shouldn't just get identical (cloned) SyntaxContextData
s, they should have the same SyntaxContext
ids.
That's because all hygiene logic runs on comparing SyntaxContext
, not SyntaxContextData
s, so two different SyntaxContexts
are considered different even if they datas are the same.
In other words, SyntaxContextData
are assumed to be unique and interned (like Symbol
s), and decoding should maintain this property.
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.
That's because all hygiene logic runs on comparing SyntaxContext, not SyntaxContextDatas, so two different SyntaxContexts are considered different even if they datas are the same.
I think this is exactly what #127279 aims to do: reuse the opaque
value to ensure it compares the correct SyntaxContext
value.
If two syntax contexts have matching (parent, outer_expn_id, outer_transparency) tuples, they shouldn't just get identical (cloned) SyntaxContextDatas, they should have the same SyntaxContext ids.
I'm confused because the old code decodes opaque
and generates a new SyntaxContext
value using new_ctxt. Following this view, this logic has always been flawed.
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.
Following this view, this logic has always been flawed.
Yep, that seems true.
I'm still investigating.
hygiene: Ensure uniqueness of `SyntaxContextData`s `SyntaxContextData`s are basically interned with `SyntaxContext`s working as keys, so they are supposed to be unique. However, currently duplicate `SyntaxContextData`s can be created during decoding from metadata or incremental cache. This PR fixes that. cc rust-lang#129827 (comment)
Following this comment
r? @petrochenkov