-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
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.
I've made some adjustments based on #139083. Looks like we can remove |
Thanks! |
☀️ Test successful - checks-actions |
What is this?This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.Comparing 5cc6072 (parent) -> d4812c8 (this PR) Test differencesShow 8 test diffsAdditionally, 8 doctest diffs were found. These are ignored, as they are noisy. Job group index Job duration changes
How to interpret the job duration changes?Job durations can vary a lot, based on the actual runner instance |
Finished benchmarking commit (d4812c8): comparison URL. Overall result: ❌ regressions - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -2.4%, secondary -3.5%)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 2.5%)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.2%, secondary -0.4%)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: 777.697s -> 777.207s (-0.06%) |
The perf result here is unexpected, this was supposed to be an improvement (and it was an improvement in the previous iteration - #129827 (comment)). This is also why I wanted to do this in smaller steps and not at once (#129827 (comment)). |
This is quite unexpected. Could we proceed like this:
|
Posted a revert here: #139130. |
Revert "Auto merge of rust-lang#129827 - bvanjoi:less-decoding, r=petrochenkov" Reverting rust-lang#129827 because of a performance regression. This reverts commit d4812c8, reversing changes made to 5cc6072. r? `@petrochenkov`
hygiene: Rewrite `apply_mark_internal` to be more understandable The previous implementation allocated new `SyntaxContext`s in the inverted order, and it was generally very hard to understand why its result matches what the `opaque` and `opaque_and_semitransparent` field docs promise. ```rust /// This context, but with all transparent and semi-transparent expansions filtered away. opaque: SyntaxContext, /// This context, but with all transparent expansions filtered away. opaque_and_semitransparent: SyntaxContext, ``` It also couldn't be easily reused for the case where the context id is pre-reserved like in rust-lang#129827. The new implementation tries to follow the docs in a more straightforward way. I did the transformation in small steps, so it indeed matches the old implementation, not just the docs. So I suggest reading only the new version.
Perf triage: This regression was addressed by the revert. @rustbot label: +perf-regression-triaged |
|
||
// Reminder: `HygieneDecodeContext` is per-crate, so there are no collisions between | ||
// raw ids from different crate metadatas. | ||
if let Some(ctxt) = inner.remapped_ctxts.get(raw_id as usize).copied().flatten() { |
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.
Removing this cache was probably a bad idea.
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 remember that the mechanism here was designed to prevent redundant locking, though I'm not entirely sure if it relates to performance. Let's wait for the performance test results to confirm.
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.
#139228 showed almost the same regressions as #129827 (comment).
@bvanjoi could you resubmit this PR with remapped_ctxts
caching restored and #129827 (comment) addressed?
hygiene: Remove all caching in syntax context decoding rust-lang#129827 unintentionally removed one caching layer in syntax context decoding (rust-lang#129827 (comment)), and it was a perf regression. However, it didn't remove all the infrastructure and locks supporting that caching layer. Let's actually try to double down on that change, remove everything and see what happens. If it doesn't work out, we'll try just try to re-land rust-lang#129827 without the `remapped_ctxts` removal. cc `@bvanjoi`
@@ -1473,29 +1415,10 @@ pub fn decode_syntax_context<D: Decoder, F: FnOnce(&mut D, u32) -> SyntaxContext | |||
Some(&ctxt) => ctxt, |
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 syntax_context_map
lookup is no longer necessary, alloc_ctxt
/apply_mark_internal
already performs it.
return ctxt; | ||
} | ||
|
||
match inner.decoding.entry(raw_id) { |
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.
The decoding
field can also be removed now.
Following this comment
r? @petrochenkov