Skip to content

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 24 commits into from
Aug 9, 2016
Merged
Show file tree
Hide file tree
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 Jul 29, 2016
c56eb4b
remap Hir(InlinedDefId) to MetaData(OriginalDefId)
nikomatsakis Jul 29, 2016
b4929d1
watch out for krate numbers being reassigned
nikomatsakis Jul 29, 2016
2797b2a
remove register_reads
nikomatsakis Jul 30, 2016
2e7df80
make metadata hashes determinstic
nikomatsakis Aug 1, 2016
903142a
dump statistics about re-use w/ -Z time-passes
nikomatsakis Aug 1, 2016
94acff1
replace graph rewriting with detecting inlined ids
nikomatsakis Aug 2, 2016
b13d504
improve log when something no longer exists
nikomatsakis Aug 2, 2016
54595ec
use memoized pattern for SizedConstraint
nikomatsakis Aug 2, 2016
bfbfe63
skip assert-dep-graph unless unit testing
nikomatsakis Aug 3, 2016
a6a97a9
rustfmt save.rs
nikomatsakis Aug 5, 2016
88b2e9a
rename KrateInfo to CrateInfo
nikomatsakis Aug 8, 2016
8fdc72f
track MIR through the dep-graph
nikomatsakis Aug 8, 2016
82b6dc2
fixup tests for new def'n of InlinedItem
nikomatsakis Aug 9, 2016
0e97240
isolate predecessor computation
nikomatsakis Aug 5, 2016
a92b1a7
make DepNode PartialOrd
nikomatsakis Aug 6, 2016
571010b
replace Name with InternedString in DefPathData
nikomatsakis Aug 6, 2016
d4bd054
add a `-Z incremental-info` flag
nikomatsakis Aug 6, 2016
8150494
add a `deterministic_hash` method to `DefPath`
nikomatsakis Aug 6, 2016
9978cbc
generalize BitMatrix to be NxM and not just NxN
nikomatsakis Aug 6, 2016
02a4703
use preds to serialize just what we need
nikomatsakis Aug 6, 2016
ecbcf1b
address comments from mw
nikomatsakis Aug 9, 2016
76eecc7
pacify the mercilous tidy
nikomatsakis Aug 9, 2016
e0b82d5
fix license
nikomatsakis Aug 9, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/librustc_incremental/persist/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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.
Copy link
Member

Choose a reason for hiding this comment

The 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)| {
Expand All @@ -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) {
Expand Down
9 changes: 7 additions & 2 deletions src/librustc_incremental/persist/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

_ => (),
}
let target = builder.map(target);
Expand Down Expand Up @@ -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| {
Expand Down