@@ -422,6 +422,9 @@ impl NodeInfo {
422
422
}
423
423
}
424
424
425
+ /// Encode a node that was promoted from the previous graph. It reads the edges directly from
426
+ /// the previous dep graph and expects all edges to already have a new dep node index assigned.
427
+ /// This avoids the overhead of constructing `EdgesVec`, which would be needed to call `encode`.
425
428
#[ inline]
426
429
fn encode_promoted < D : Deps > (
427
430
e : & mut FileEncoder ,
@@ -433,6 +436,8 @@ impl NodeInfo {
433
436
) -> usize {
434
437
let edges = previous. edge_targets_from ( prev_index) ;
435
438
let edge_count = edges. size_hint ( ) . 0 ;
439
+
440
+ // Find the highest edge in the new dep node indices
436
441
let edge_max =
437
442
edges. clone ( ) . map ( |i| prev_index_to_index[ i] . unwrap ( ) . as_u32 ( ) ) . max ( ) . unwrap_or ( 0 ) ;
438
443
@@ -502,7 +507,10 @@ impl<D: Deps> EncoderState<D> {
502
507
self . total_edge_count += edge_count;
503
508
504
509
if let Some ( record_graph) = & record_graph {
510
+ // Call `edges` before the outlined code to allow the closure to be optimized out.
505
511
let edges = edges ( self ) ;
512
+
513
+ // Outline the build of the full dep graph as it's typically disabled and cold.
506
514
outline ( move || {
507
515
// Do not ICE when a query is called from within `with_query`.
508
516
if let Some ( record_graph) = & mut record_graph. try_lock ( ) {
@@ -514,6 +522,7 @@ impl<D: Deps> EncoderState<D> {
514
522
if let Some ( stats) = & mut self . stats {
515
523
let kind = node. kind ;
516
524
525
+ // Outline the stats code as it's typically disabled and cold.
517
526
outline ( move || {
518
527
let stat =
519
528
stats. entry ( kind) . or_insert ( Stat { kind, node_counter : 0 , edge_counter : 0 } ) ;
@@ -525,6 +534,7 @@ impl<D: Deps> EncoderState<D> {
525
534
index
526
535
}
527
536
537
+ /// Encodes a node to the current graph.
528
538
fn encode_node (
529
539
& mut self ,
530
540
node : & NodeInfo ,
@@ -539,8 +549,14 @@ impl<D: Deps> EncoderState<D> {
539
549
)
540
550
}
541
551
552
+ /// Encodes a node that was promoted from the previous graph. It reads the information directly from
553
+ /// the previous dep graph for performance reasons.
554
+ ///
555
+ /// This differs from `encode_node` where you have to explictly provide the relevant `NodeInfo`.
556
+ ///
557
+ /// It expects all edges to already have a new dep node index assigned.
542
558
#[ inline]
543
- fn promote_node (
559
+ fn encode_promoted_node (
544
560
& mut self ,
545
561
prev_index : SerializedDepNodeIndex ,
546
562
record_graph : & Option < Lock < DepGraphQuery > > ,
@@ -698,14 +714,16 @@ impl<D: Deps> GraphEncoder<D> {
698
714
self . status . lock ( ) . as_mut ( ) . unwrap ( ) . encode_node ( & node, & self . record_graph )
699
715
}
700
716
717
+ /// Encodes a node that was promoted from the previous graph. It reads the information directly from
718
+ /// the previous dep graph and expects all edges to already have a new dep node index assigned.
701
719
#[ inline]
702
- pub ( crate ) fn promote (
720
+ pub ( crate ) fn send_promoted (
703
721
& self ,
704
722
prev_index : SerializedDepNodeIndex ,
705
723
prev_index_to_index : & IndexVec < SerializedDepNodeIndex , Option < DepNodeIndex > > ,
706
724
) -> DepNodeIndex {
707
725
let _prof_timer = self . profiler . generic_activity ( "incr_comp_encode_dep_graph" ) ;
708
- self . status . lock ( ) . as_mut ( ) . unwrap ( ) . promote_node (
726
+ self . status . lock ( ) . as_mut ( ) . unwrap ( ) . encode_promoted_node (
709
727
prev_index,
710
728
& self . record_graph ,
711
729
prev_index_to_index,
0 commit comments