Encode spans relative to the enclosing item#84373
Conversation
This comment has been minimized.
This comment has been minimized.
|
I don't like the idea of keeping the ID in |
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
|
⌛ Trying commit d861775a3095b6bc7b23e4dc2acfb30a82f104c2 with merge 53c860c88de8437287861ee8c26eaedbe95dd7fb... |
This comment has been minimized.
This comment has been minimized.
On the one hand, I agree with you, putting the ID in the SpanData is a bad hack, and invites silent invalidations. I shall think a bit more about it. Creating a |
|
☀️ Try build successful - checks-actions |
|
Queued 53c860c88de8437287861ee8c26eaedbe95dd7fb with parent 2b68027, future comparison URL. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
perf report : bad (I mean don't look, its really bad). |
|
@bors try @rust-timer queue |
|
Awaiting bors try build completion. @rustbot label: +S-waiting-on-perf |
|
⌛ Trying commit f9e65cc5e495f6943d3c02cc4c4f2c30809379f2 with merge 4bbad094c33b7feb41e0f016c658bccffd0793bb... |
|
☀️ Try build successful - checks-actions |
|
Queued 4bbad094c33b7feb41e0f016c658bccffd0793bb with parent fcce644, future comparison URL. |
|
Finished benchmarking try commit (4bbad094c33b7feb41e0f016c658bccffd0793bb): comparison url. Summary: This change led to large relevant regressions 😿 in compiler performance.
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. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @bors rollup=never |
|
I don't have any more comments about the code, I'd just like to identify the regression sources. |
|
Well, the regressions are not great but not catastrophic either. The compiler team decided to go ahead with this change via MCP rust-lang/compiler-team#443 in order to enable further experimentation in this area. So I would say we merge the PR now. The feature is behind a flag and we can still revert it if it turns out to be a dead end. @cjgillot, you can r=michaelwoerister,petrochenkov after fixing the conflicts. |
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #80522) made this pull request unmergeable. Please resolve the merge conflicts. |
We force the relative span's parent to be absolute. This avoids having to handle long dependency chains.
Now that we encode spans relative to the items, the item's own span is never actually hashed as part of the HIR. In consequence, we explicitly include it in the crate hash to avoid missing cross-crate invalidations.
We only do this operation when incremental compilation is enabled. This avoids pessimizing the span handling for non-incremental compilation.
This comment has been minimized.
This comment has been minimized.
|
@bors r=michaelwoerister,petrochenkov About the perf regression: this PR implements an opt-in feature to reduce span-related recomputations for incr-comp. Measurements in #84762 show up to -25% instruction reduction when enabled. When disabled, the perf hit appears to be a consistent 1-2% instruction hit. |
|
📌 Commit 7842b80 has been approved by |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (547d937): comparison url. Summary: This change led to large relevant regressions 😿 in compiler performance.
If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf. Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression |
So seems justified and action on this PR not expected. |
The aim of this PR is to avoid recomputing queries when code is moved without modification.
MCP at rust-lang/compiler-team#443
This is achieved by :
source_span(LocalDefId)query when we translate a span from the short (Span) representation to its explicit (SpanData) representation.Since all client code uses
Span, step 3 ensures that all manipulationsof span byte positions actually create the dependency edge between
the caller and the
source_span(LocalDefId).This query return the actual absolute span of the parent item.
As a consequence, any source code motion that changes the absolute byte position of a node will either:
source_span, and trigger the incremental recomputation of all code thatdepends on the span's absolute byte position.
With this scheme, I believe the dependency tracking to be accurate.
For the moment, the spans are marked during lowering.
I'd rather do this during def-collection,
but the AST MutVisitor is not practical enough just yet.
The only difference is that we attach macro-expanded spans
to their expansion point instead of the macro itself.