-
Notifications
You must be signed in to change notification settings - Fork 13.8k
Encode spans relative to the enclosing item #84373
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
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 |
This comment has been minimized.
This comment has been minimized.
890e381
to
7842b80
Compare
@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.