-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Restructure metadata encoder to track deps precisely #35684
Restructure metadata encoder to track deps precisely #35684
Conversation
6f39c84
to
48a40dc
Compare
//! | ||
//! In addition to the offset, we need to track the data that was used | ||
//! to generate the contents of each `data_item`. This is so that we | ||
//! can figure out which HIR nodes contributors to that data for |
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.
'contributed'
I like it! I'm definitely in favor of spreading the use of this pattern, it should indeed reduce the number of data leaks a lot. |
fn read(&self, tcx: TyCtxt); | ||
} | ||
|
||
impl DepGraphRead for 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.
Why implement this? It seems open the door missing edges.
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.
Why implement this? It seems open the door missing edges.
A good question. I wanted it for indices that we pass down (e.g., the index of a variant), but it'd be semantically better to have some newtyped usize I suppose.
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.
You could always pass such instances as part of a FromId
wrapper, right?
@michaelwoerister and I chatted a bit on IRC and decided to remove the |
d4d6380
to
ef96c9d
Compare
} | ||
} | ||
} | ||
|
||
impl<'a, 'tcx, 'encoder> ItemContentBuilder<'a, 'tcx, 'encoder> { | ||
/// Encode data for the given variant of the given ADT. The | ||
/// indices of the variant is untracked: this is ok because we |
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.
indices => index
r=me with the typos fixed. |
ef96c9d
to
f0e5161
Compare
@bors r=mw |
📌 Commit f0e5161 has been approved by |
f0e5161
to
2f78c91
Compare
@bors r=mw |
📌 Commit 2f78c91 has been approved by |
|
☔ The latest upstream changes (presumably #35605) made this pull request unmergeable. Please resolve the merge conflicts. |
@jonas-schievink so weird; I do not see these locally ( |
The idea is that ItemContentBuilder is a base-type of IndexBuilder.
The idea is that, this way, we can cleanly isolate ALL state that is being passed, since it goes as an argument to the fn pointer.
Also write a comment explaining the system.
The comment explains the `index-builder` pattern. We no longer need the `Deref/DerefMut` relationship, and it seems nicer without it.
The idea is that a `usize` is sort of ambiguous: in this case, it represents indices that do not need tracking, but it could as easily be some data read out from a tracked location, and hence represent tracked data. Therefore, we add an `Untracked` type that lets user assert that value is not tracked. Also correct various typos.
2f78c91
to
37d974f
Compare
@bors r=mw |
📌 Commit 37d974f has been approved by |
⌛ Testing commit 37d974f with merge 895ed0e... |
💔 Test failed - auto-win-msvc-64-opt-rustbuild |
@bors retry |
/me hopes |
Restructure metadata encoder to track deps precisely This issue restructures meta-data encoding to track dependencies very precisely. It uses a cute technique I hope to spread elsewhere, where we can guard the data flowing into a new dep-graph task and ensure that it is not "leaking" information from the outside, which would result in missing edges. There are no tests because we don't know of any bugs in the old system, but it's clear that there was leaked data. The commit series is standalone, but the refactorings are kind of "windy". It's a good idea to read the comment in `src/librustc_metadata/index_builder.rs` to get a feeling for the overall strategy I was aiming at. In several cases, I wound up adding some extra hashtable lookups, I think primarily for looking up `AdtDef` instances. We could remove these by implementing `DepGraphRead` for an `AdtDef` and then having it register a read to the adt-defs table, I guess, but I doubt it is really noticeable. Eventually I think I'd like to extend this pattern to the dep-graph more generally, since it effectively guarantees that data cannot leak. Fixes #35111. r? @michaelwoerister
This issue restructures meta-data encoding to track dependencies very precisely. It uses a cute technique I hope to spread elsewhere, where we can guard the data flowing into a new dep-graph task and ensure that it is not "leaking" information from the outside, which would result in missing edges. There are no tests because we don't know of any bugs in the old system, but it's clear that there was leaked data.
The commit series is standalone, but the refactorings are kind of "windy". It's a good idea to read the comment in
src/librustc_metadata/index_builder.rs
to get a feeling for the overall strategy I was aiming at.In several cases, I wound up adding some extra hashtable lookups, I think primarily for looking up
AdtDef
instances. We could remove these by implementingDepGraphRead
for anAdtDef
and then having it register a read to the adt-defs table, I guess, but I doubt it is really noticeable.Eventually I think I'd like to extend this pattern to the dep-graph more generally, since it effectively guarantees that data cannot leak.
Fixes #35111.
r? @michaelwoerister