@@ -92,6 +92,9 @@ pub struct SerializedDepGraph {
92
92
/// Stores a map from fingerprints to nodes per dep node kind.
93
93
/// This is the reciprocal of `nodes`.
94
94
index : Vec < UnhashMap < PackedFingerprint , SerializedDepNodeIndex > > ,
95
+ /// The number of previous compilation sessions. This is used to generate
96
+ /// unique anon dep nodes per session.
97
+ session_count : u64 ,
95
98
}
96
99
97
100
impl SerializedDepGraph {
@@ -146,6 +149,11 @@ impl SerializedDepGraph {
146
149
pub fn node_count ( & self ) -> usize {
147
150
self . nodes . len ( )
148
151
}
152
+
153
+ #[ inline]
154
+ pub fn session_count ( & self ) -> u64 {
155
+ self . session_count
156
+ }
149
157
}
150
158
151
159
/// A packed representation of an edge's start index and byte width.
@@ -252,6 +260,8 @@ impl SerializedDepGraph {
252
260
. map ( |_| UnhashMap :: with_capacity_and_hasher ( d. read_u32 ( ) as usize , Default :: default ( ) ) )
253
261
. collect ( ) ;
254
262
263
+ let session_count = d. read_u64 ( ) ;
264
+
255
265
for ( idx, node) in nodes. iter_enumerated ( ) {
256
266
if index[ node. kind . as_usize ( ) ] . insert ( node. hash , idx) . is_some ( ) {
257
267
// Side effect nodes can have duplicates
@@ -273,6 +283,7 @@ impl SerializedDepGraph {
273
283
edge_list_indices,
274
284
edge_list_data,
275
285
index,
286
+ session_count,
276
287
} )
277
288
}
278
289
}
@@ -601,7 +612,7 @@ impl<D: Deps> EncoderState<D> {
601
612
stats : _,
602
613
kind_stats,
603
614
marker : _,
604
- previous : _ ,
615
+ previous,
605
616
} = self ;
606
617
607
618
let node_count = total_node_count. try_into ( ) . unwrap ( ) ;
@@ -612,6 +623,8 @@ impl<D: Deps> EncoderState<D> {
612
623
count. encode ( & mut encoder) ;
613
624
}
614
625
626
+ previous. session_count . checked_add ( 1 ) . unwrap ( ) . encode ( & mut encoder) ;
627
+
615
628
debug ! ( ?node_count, ?edge_count) ;
616
629
debug ! ( "position: {:?}" , encoder. position( ) ) ;
617
630
IntEncodedWithFixedSize ( node_count) . encode ( & mut encoder) ;
0 commit comments