@@ -13,6 +13,7 @@ use std::fmt::Debug;
1313use std:: hash:: Hash ;
1414use std:: marker:: PhantomData ;
1515use std:: sync:: atomic:: Ordering ;
16+ use std:: sync:: Arc ;
1617
1718use super :: query:: DepGraphQuery ;
1819use super :: serialized:: { GraphEncoder , SerializedDepGraph , SerializedDepNodeIndex } ;
@@ -81,7 +82,7 @@ pub(crate) struct DepGraphData<D: Deps> {
8182
8283 /// The dep-graph from the previous compilation session. It contains all
8384 /// nodes and edges as well as all fingerprints of nodes that have them.
84- previous : SerializedDepGraph ,
85+ previous : Arc < SerializedDepGraph > ,
8586
8687 colors : DepNodeColorMap ,
8788
@@ -113,7 +114,7 @@ where
113114impl < D : Deps > DepGraph < D > {
114115 pub fn new (
115116 profiler : & SelfProfilerRef ,
116- prev_graph : SerializedDepGraph ,
117+ prev_graph : Arc < SerializedDepGraph > ,
117118 prev_work_products : WorkProductMap ,
118119 encoder : FileEncoder ,
119120 record_graph : bool ,
@@ -127,6 +128,7 @@ impl<D: Deps> DepGraph<D> {
127128 encoder,
128129 record_graph,
129130 record_stats,
131+ prev_graph. clone ( ) ,
130132 ) ;
131133
132134 let colors = DepNodeColorMap :: new ( prev_graph_node_count) ;
@@ -1084,6 +1086,7 @@ impl<D: Deps> CurrentDepGraph<D> {
10841086 encoder : FileEncoder ,
10851087 record_graph : bool ,
10861088 record_stats : bool ,
1089+ previous : Arc < SerializedDepGraph > ,
10871090 ) -> Self {
10881091 use std:: time:: { SystemTime , UNIX_EPOCH } ;
10891092
@@ -1116,6 +1119,7 @@ impl<D: Deps> CurrentDepGraph<D> {
11161119 record_graph,
11171120 record_stats,
11181121 profiler,
1122+ previous,
11191123 ) ,
11201124 new_node_to_index : Sharded :: new ( || {
11211125 FxHashMap :: with_capacity_and_hasher (
@@ -1236,16 +1240,14 @@ impl<D: Deps> CurrentDepGraph<D> {
12361240 match prev_index_to_index[ prev_index] {
12371241 Some ( dep_node_index) => dep_node_index,
12381242 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) ;
12461244 prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
12471245 #[ 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+ ) ;
12491251 dep_node_index
12501252 }
12511253 }
0 commit comments