-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Optimize dep-graph serialization and improve meta-data hashing #35406
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
9294f8e
hash foreign items too
nikomatsakis c56eb4b
remap Hir(InlinedDefId) to MetaData(OriginalDefId)
nikomatsakis b4929d1
watch out for krate numbers being reassigned
nikomatsakis 2797b2a
remove register_reads
nikomatsakis 2e7df80
make metadata hashes determinstic
nikomatsakis 903142a
dump statistics about re-use w/ -Z time-passes
nikomatsakis 94acff1
replace graph rewriting with detecting inlined ids
nikomatsakis b13d504
improve log when something no longer exists
nikomatsakis 54595ec
use memoized pattern for SizedConstraint
nikomatsakis bfbfe63
skip assert-dep-graph unless unit testing
nikomatsakis a6a97a9
rustfmt save.rs
nikomatsakis 88b2e9a
rename KrateInfo to CrateInfo
nikomatsakis 8fdc72f
track MIR through the dep-graph
nikomatsakis 82b6dc2
fixup tests for new def'n of InlinedItem
nikomatsakis 0e97240
isolate predecessor computation
nikomatsakis a92b1a7
make DepNode PartialOrd
nikomatsakis 571010b
replace Name with InternedString in DefPathData
nikomatsakis d4bd054
add a `-Z incremental-info` flag
nikomatsakis 8150494
add a `deterministic_hash` method to `DefPath`
nikomatsakis 9978cbc
generalize BitMatrix to be NxM and not just NxN
nikomatsakis 02a4703
use preds to serialize just what we need
nikomatsakis ecbcf1b
address comments from mw
nikomatsakis 76eecc7
pacify the mercilous tidy
nikomatsakis e0b82d5
fix license
nikomatsakis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,10 +113,28 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
// TODO -- this could be more efficient if we integrated the `DefIdDirectory` and | ||
// pred set more deeply | ||
|
||
// Compute the set of Hir nodes whose data has changed or which have been removed. | ||
// Compute the set of Hir nodes whose data has changed or which | ||
// have been removed. These are "raw" source nodes, which means | ||
// that they still use the original `DefPathIndex` values from the | ||
// encoding, rather than having been retraced to a `DefId`. The | ||
// reason for this is that this way we can include nodes that have | ||
// been removed (which no longer have a `DefId` in the current | ||
// compilation). | ||
let dirty_raw_source_nodes = dirty_nodes(tcx, &serialized_dep_graph.hashes, &retraced); | ||
|
||
// Create a (maybe smaller) list of | ||
// Create a list of (raw-source-node -> | ||
// retracted-target-node) edges. In the process of retracing the | ||
// target nodes, we may discover some of them def-paths no longer exist, | ||
// in which case there is no need to mark the corresopnding nodes as dirty | ||
// (they are just not present). So this list may be smaller than the original. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
// | ||
// Note though that in the common case the target nodes are | ||
// `DepNode::WorkProduct` instances, and those don't have a | ||
// def-id, so they will never be considered to not exist. Instead, | ||
// we do a secondary hashing step (later, in trans) when we know | ||
// the set of symbols that go into a work-product: if any symbols | ||
// have been removed (or added) the hash will be different and | ||
// we'll ignore the work-product then. | ||
let retraced_edges: Vec<_> = | ||
serialized_dep_graph.edges.iter() | ||
.filter_map(|&(ref raw_source_node, ref raw_target_node)| { | ||
|
@@ -125,7 +143,8 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, | |
}) | ||
.collect(); | ||
|
||
// Compute which work-products have changed. | ||
// Compute which work-products have an input that has changed or | ||
// been removed. Put the dirty ones into a set. | ||
let mut dirty_target_nodes = FnvHashSet(); | ||
for &(raw_source_node, ref target_node) in &retraced_edges { | ||
if dirty_raw_source_nodes.contains(raw_source_node) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,12 @@ pub fn encode_dep_graph(preds: &Predecessors, | |
let mut edges = vec![]; | ||
for (&target, sources) in &preds.inputs { | ||
match *target { | ||
DepNode::MetaData(_) => continue, // see encode_metadata_hashes instead | ||
DepNode::MetaData(ref def_id) => { | ||
// Metadata *targets* are always local metadata nodes. We handle | ||
// those in `encode_metadata_hashes`, which comes later. | ||
assert!(def_id.is_local()); | ||
continue; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
_ => (), | ||
} | ||
let target = builder.map(target); | ||
|
@@ -186,7 +191,7 @@ pub fn encode_metadata_hashes(tcx: TyCtxt, | |
// Create a vector containing a pair of (source-id, hash). | ||
// The source-id is stored as a `DepNode<u64>`, where the u64 | ||
// is the det. hash of the def-path. This is convenient | ||
// because we can sort this to get a table ordering across | ||
// because we can sort this to get a stable ordering across | ||
// compilations, even if the def-ids themselves have changed. | ||
let mut hashes: Vec<(DepNode<u64>, u64)> = sources.iter() | ||
.map(|dep_node| { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
👍