@@ -13,6 +13,7 @@ use std::fmt::Debug;
13
13
use std::hash::Hash;
14
14
use std::marker::PhantomData;
15
15
use std::sync::atomic::Ordering;
16
+ use std::sync::Arc;
16
17
17
18
use super::query::DepGraphQuery;
18
19
use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex};
@@ -81,7 +82,7 @@ pub(crate) struct DepGraphData<D: Deps> {
81
82
82
83
/// The dep-graph from the previous compilation session. It contains all
83
84
/// nodes and edges as well as all fingerprints of nodes that have them.
84
- previous: SerializedDepGraph,
85
+ previous: Arc< SerializedDepGraph> ,
85
86
86
87
colors: DepNodeColorMap,
87
88
@@ -113,7 +114,7 @@ where
113
114
impl<D: Deps> DepGraph<D> {
114
115
pub fn new(
115
116
profiler: &SelfProfilerRef,
116
- prev_graph: SerializedDepGraph,
117
+ prev_graph: Arc< SerializedDepGraph> ,
117
118
prev_work_products: WorkProductMap,
118
119
encoder: FileEncoder,
119
120
record_graph: bool,
@@ -127,6 +128,7 @@ impl<D: Deps> DepGraph<D> {
127
128
encoder,
128
129
record_graph,
129
130
record_stats,
131
+ prev_graph.clone(),
130
132
);
131
133
132
134
let colors = DepNodeColorMap::new(prev_graph_node_count);
@@ -1084,6 +1086,7 @@ impl<D: Deps> CurrentDepGraph<D> {
1084
1086
encoder: FileEncoder,
1085
1087
record_graph: bool,
1086
1088
record_stats: bool,
1089
+ previous: Arc<SerializedDepGraph>,
1087
1090
) -> Self {
1088
1091
use std::time::{SystemTime, UNIX_EPOCH};
1089
1092
@@ -1116,6 +1119,7 @@ impl<D: Deps> CurrentDepGraph<D> {
1116
1119
record_graph,
1117
1120
record_stats,
1118
1121
profiler,
1122
+ previous,
1119
1123
),
1120
1124
new_node_to_index: Sharded::new(|| {
1121
1125
FxHashMap::with_capacity_and_hasher(
@@ -1236,16 +1240,14 @@ impl<D: Deps> CurrentDepGraph<D> {
1236
1240
match prev_index_to_index[prev_index] {
1237
1241
Some(dep_node_index) => dep_node_index,
1238
1242
None => {
1239
- let key = prev_graph.index_to_node(prev_index);
1240
- let edges = prev_graph
1241
- .edge_targets_from(prev_index)
1242
- .map(|i| prev_index_to_index[i].unwrap())
1243
- .collect();
1244
- let fingerprint = prev_graph.fingerprint_by_index(prev_index);
1245
- let dep_node_index = self.encoder.send(key, fingerprint, edges);
1243
+ let dep_node_index = self.encoder.send_promoted(prev_index, &*prev_index_to_index);
1246
1244
prev_index_to_index[prev_index] = Some(dep_node_index);
1247
1245
#[cfg(debug_assertions)]
1248
- self.record_edge(dep_node_index, key, fingerprint);
1246
+ self.record_edge(
1247
+ dep_node_index,
1248
+ prev_graph.index_to_node(prev_index),
1249
+ prev_graph.fingerprint_by_index(prev_index),
1250
+ );
1249
1251
dep_node_index
1250
1252
}
1251
1253
}
0 commit comments