Skip to content

Commit acb73db

Browse files
committed
Auto merge of #44772 - michaelwoerister:new-graph, r=nikomatsakis
incr.comp.: Add new DepGraph implementation. This commits does a few things: 1. It adds the new dep-graph implementation -- *in addition* to the old one. This way we can start testing the new implementation without switching all tests at once. 2. It persists the new dep-graph (which includes query result fingerprints) to the incr. comp. caching directory and also loads this data. 3. It removes support for loading fingerprints of metadata imported from other crates (except for when running autotests). This is not needed anymore with red/green. It could provide a performance advantage but that's yet to be determined. For now, as red/green is not fully implemented yet, the cross-crate incremental tests are disabled. Note, this PR is based on top of soon-to-be-merged #44696 and only the last 4 commits are new: ``` - incr.comp.: Initial implemenation of append-only dep-graph. (c90147c) - incr.comp.: Do some various cleanup. (8ce20c5) - incr.comp.: Serialize and deserialize new DepGraph. (0e13c1a) - incr.comp.: Remove support for loading metadata fingerprints. (270a134) EDIT 2: - incr.comp.: Make #[rustc_dirty/clean] test for fingerprint equality ... (d8f7ff9) ``` (EDIT: GH displays the commits in the wrong order for some reason) Also note that this PR is expected to certainly result in performance regressions in the incr. comp. test cases, since we are adding quite a few things (a whole additional dep-graph, for example) without removing anything. End-to-end performance measurements will only make sense again after red/green is enabled and all the legacy tracking has been turned off. EDIT 2: Pushed another commit that makes the `#[rustc_dirty]`/`#[rustc_clean]` based autotests compared query result fingerprints instead of testing `DepNode` existence.
2 parents 24831c7 + 89aec1e commit acb73db

File tree

34 files changed

+662
-535
lines changed

34 files changed

+662
-535
lines changed

src/librustc/dep_graph/dep_node.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
//! user of the `DepNode` API of having to know how to compute the expected
6161
//! fingerprint for a given set of node parameters.
6262
63-
use hir::def_id::{CrateNum, DefId, DefIndex};
63+
use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX};
6464
use hir::map::DefPathHash;
6565
use hir::{HirId, ItemLocalId};
6666

@@ -420,7 +420,7 @@ define_dep_nodes!( <'tcx>
420420
[input] Hir(DefId),
421421

422422
// Represents metadata from an extern crate.
423-
[input] MetaData(DefId),
423+
[input] CrateMetadata(CrateNum),
424424

425425
// Represents some artifact that we save to disk. Note that these
426426
// do not have a def-id as part of their identifier.
@@ -678,6 +678,22 @@ impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefIndex,
678678
}
679679
}
680680

681+
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (CrateNum,) {
682+
const CAN_RECONSTRUCT_QUERY_KEY: bool = true;
683+
684+
fn to_fingerprint(&self, tcx: TyCtxt) -> Fingerprint {
685+
let def_id = DefId {
686+
krate: self.0,
687+
index: CRATE_DEF_INDEX,
688+
};
689+
tcx.def_path_hash(def_id).0
690+
}
691+
692+
fn to_debug_str(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> String {
693+
tcx.crate_name(self.0).as_str().to_string()
694+
}
695+
}
696+
681697
impl<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> DepNodeParams<'a, 'gcx, 'tcx> for (DefId, DefId) {
682698
const CAN_RECONSTRUCT_QUERY_KEY: bool = false;
683699

src/librustc/dep_graph/edges.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::mem;
1717
use super::{DepGraphQuery, DepKind, DepNode};
1818
use super::debug::EdgeFilter;
1919

20-
pub struct DepGraphEdges {
20+
pub(super) struct DepGraphEdges {
2121
nodes: Vec<DepNode>,
2222
indices: FxHashMap<DepNode, DepNodeIndex>,
2323
edges: FxHashSet<(DepNodeIndex, DepNodeIndex)>,
@@ -31,8 +31,8 @@ pub struct DepGraphEdges {
3131
}
3232

3333
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
34-
pub struct DepNodeIndex {
35-
index: u32
34+
pub(super) struct DepNodeIndex {
35+
index: u32,
3636
}
3737

3838
impl DepNodeIndex {

0 commit comments

Comments
 (0)