-
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
use old ctx if has same expand environment during decode span #127279
Conversation
Could you check if the issue reproduces with #119412? |
Unfortunately, this issue still exists |
Whether |
Yep, but I think this might be an omission point during decoding spans that come from the disk cache: sometimes it may not be necessary to generate a new This means the span_b_ctx -> SyntaxContextData {
opaque: span_a.opaque,
opaque_and_semitransparent: span_a.opaque_and_semitransparent,
// ....
} I'm not sure if it's completely correct, but it's more convincing than simply disabling the disk cache for ident spans. |
def_ident_span
from disk
I think the new fix is in the right direction. In outer_expn: ExpnId,
outer_transparency: Transparency,
parent: SyntaxContext, and these two fields are caches / precomputed values for some operations on the substantial fields /// 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, The last field seems to also be ignored during decoding (with a reasonable explanation). /// Name of the crate to which `$crate` with this context would resolve.
dollar_crate_name: Symbol, So there are two possible strategies for encoding/decoding
|
As you can see, the fields The content of span which need to encode is: span_a_ctx -> SyntaxContextData {
opaque: span_a_ctx,
//~^ note that `span_a_data.opaque` and `span_a_ctx` have the same value
// ....
} And during the second compilation:
|
@bvanjoi any updates on this? |
@bors r+ |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#127279 (use old ctx if has same expand environment during decode span) - rust-lang#127945 (Implement `debug_more_non_exhaustive`) - rust-lang#128941 ( Improve diagnostic-related lints: `untranslatable_diagnostic` & `diagnostic_outside_of_impl`) - rust-lang#129070 (Point at explicit `'static` obligations on a trait) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation) - rust-lang#129231 (improve submodule updates) - rust-lang#129264 (Update `library/Cargo.toml` in weekly job) - rust-lang#129284 (rustdoc: animate the `:target` highlight) - rust-lang#129302 (compiletest: use `std::fs::remove_dir_all` now that it is available) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#127279 (use old ctx if has same expand environment during decode span) - rust-lang#127945 (Implement `debug_more_non_exhaustive`) - rust-lang#128941 ( Improve diagnostic-related lints: `untranslatable_diagnostic` & `diagnostic_outside_of_impl`) - rust-lang#129070 (Point at explicit `'static` obligations on a trait) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation) - rust-lang#129231 (improve submodule updates) - rust-lang#129264 (Update `library/Cargo.toml` in weekly job) - rust-lang#129284 (rustdoc: animate the `:target` highlight) - rust-lang#129302 (compiletest: use `std::fs::remove_dir_all` now that it is available) r? `@ghost` `@rustbot` modify labels: rollup
use old ctx if has same expand environment during decode span Fixes rust-lang#112680 The root reason why rust-lang#112680 failed with incremental compilation on the second attempt is the difference in `opaque` between the span of the field [`ident`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_typeck/src/expr.rs#L2348) and the span in the incremental cache at `tcx.def_ident_span(field.did)`. - Let's call the span of `ident` as `span_a`, which is generated by [`apply_mark_internal`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/hygiene.rs#L553-L554). Its content is similar to: ```rs span_a_ctx -> SyntaxContextData { opaque: span_a_ctx, opaque_and_semitransparent: span_a_ctx, // .... } ``` - And call the span of `tcx.def_ident_span` as `span_b`, which is generated by [`decode_syntax_context`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/hygiene.rs#L1390). Its content is: ```rs span_b_ctx -> SyntaxContextData { opaque: span_b_ctx, // note `span_b_ctx` is not same as `span_a_ctx` opaque_and_semitransparent: span_b_ctx, // .... } ``` Although they have the same `parent` (both refer to the root) and `outer_expn`, I cannot find the specific connection between them. Therefore, I chose a solution that may not be the best: give up the incremental compile cache to ensure we can use `span_a` in this case. r? ``@petrochenkov`` Do you have any advice on this? Or perhaps this solution is acceptable?
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#127279 (use old ctx if has same expand environment during decode span) - rust-lang#127945 (Implement `debug_more_non_exhaustive`) - rust-lang#128941 ( Improve diagnostic-related lints: `untranslatable_diagnostic` & `diagnostic_outside_of_impl`) - rust-lang#129070 (Point at explicit `'static` obligations on a trait) - rust-lang#129187 (bootstrap: fix clean's remove_dir_all implementation) - rust-lang#129231 (improve submodule updates) - rust-lang#129264 (Update `library/Cargo.toml` in weekly job) - rust-lang#129284 (rustdoc: animate the `:target` highlight) - rust-lang#129302 (compiletest: use `std::fs::remove_dir_all` now that it is available) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#127279 - bvanjoi:fix-112680, r=petrochenkov use old ctx if has same expand environment during decode span Fixes rust-lang#112680 The root reason why rust-lang#112680 failed with incremental compilation on the second attempt is the difference in `opaque` between the span of the field [`ident`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_hir_typeck/src/expr.rs#L2348) and the span in the incremental cache at `tcx.def_ident_span(field.did)`. - Let's call the span of `ident` as `span_a`, which is generated by [`apply_mark_internal`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/hygiene.rs#L553-L554). Its content is similar to: ```rs span_a_ctx -> SyntaxContextData { opaque: span_a_ctx, opaque_and_semitransparent: span_a_ctx, // .... } ``` - And call the span of `tcx.def_ident_span` as `span_b`, which is generated by [`decode_syntax_context`](https://github.com/rust-lang/rust/blob/master/compiler/rustc_span/src/hygiene.rs#L1390). Its content is: ```rs span_b_ctx -> SyntaxContextData { opaque: span_b_ctx, // note `span_b_ctx` is not same as `span_a_ctx` opaque_and_semitransparent: span_b_ctx, // .... } ``` Although they have the same `parent` (both refer to the root) and `outer_expn`, I cannot find the specific connection between them. Therefore, I chose a solution that may not be the best: give up the incremental compile cache to ensure we can use `span_a` in this case. r? `@petrochenkov` Do you have any advice on this? Or perhaps this solution is acceptable?
As a heads up, this seems to have been responsible for the (minor) incr-patched regressions reported on rollup PR #129365, as you can see from #129365 (comment) Having said that, the degree of the regression here is minor, and the fix here is patching over a legitimate problem. So I am not going to actually mark this with the perf regression label. Nonetheless It might be worth still investigating the potential deeper cause of the problem being patched over, as described by @petrochenkov above. If we were to do that, we might be able to revert this PR. (Who knows what end effect all that will have on performance; its unknown, so I'm not going to claim it will recover the minor performance regression flagged above...) |
…xt, r=<try> dont clone old syntax context I guess this regression was caused by too many clones, so this is an attempt to use the old value rather than cloning it. Perhaps a better approach would be to ensure that only the substantial fields mentioned in this [comment](rust-lang#127279 (comment)) are cacheable. Anyway, let's run a perf test to see if this can solve the problem. r? `@pnkfelix` or `@petrochenkov`
perform less decoding if it has the same syntax context Following this [comment](rust-lang#127279 (comment)) r? `@petrochenkov`
perform less decoding if it has the same syntax context Following this [comment](rust-lang#127279 (comment)) r? `@petrochenkov`
Fixes #112680
The root reason why #112680 failed with incremental compilation on the second attempt is the difference in
opaque
between the span of the fieldident
and the span in the incremental cache attcx.def_ident_span(field.did)
.ident
asspan_a
, which is generated byapply_mark_internal
. Its content is similar to:tcx.def_ident_span
asspan_b
, which is generated bydecode_syntax_context
. Its content is:Although they have the same
parent
(both refer to the root) andouter_expn
, I cannot find the specific connection between them. Therefore, I chose a solution that may not be the best: give up the incremental compile cache to ensure we can usespan_a
in this case.r? @petrochenkov Do you have any advice on this? Or perhaps this solution is acceptable?