@@ -422,6 +422,9 @@ impl NodeInfo {
422422 }
423423 }
424424
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`.
425428 #[ inline]
426429 fn encode_promoted < D : Deps > (
427430 e : & mut FileEncoder ,
@@ -433,6 +436,8 @@ impl NodeInfo {
433436 ) -> usize {
434437 let edges = previous. edge_targets_from ( prev_index) ;
435438 let edge_count = edges. size_hint ( ) . 0 ;
439+
440+ // Find the highest edge in the new dep node indices
436441 let edge_max =
437442 edges. clone ( ) . map ( |i| prev_index_to_index[ i] . unwrap ( ) . as_u32 ( ) ) . max ( ) . unwrap_or ( 0 ) ;
438443
@@ -502,7 +507,10 @@ impl<D: Deps> EncoderState<D> {
502507 self . total_edge_count += edge_count;
503508
504509 if let Some ( record_graph) = & record_graph {
510+ // Call `edges` before the outlined code to allow the closure to be optimized out.
505511 let edges = edges ( self ) ;
512+
513+ // Outline the build of the full dep graph as it's typically disabled and cold.
506514 outline ( move || {
507515 // Do not ICE when a query is called from within `with_query`.
508516 if let Some ( record_graph) = & mut record_graph. try_lock ( ) {
@@ -514,6 +522,7 @@ impl<D: Deps> EncoderState<D> {
514522 if let Some ( stats) = & mut self . stats {
515523 let kind = node. kind ;
516524
525+ // Outline the stats code as it's typically disabled and cold.
517526 outline ( move || {
518527 let stat =
519528 stats. entry ( kind) . or_insert ( Stat { kind, node_counter : 0 , edge_counter : 0 } ) ;
@@ -525,6 +534,7 @@ impl<D: Deps> EncoderState<D> {
525534 index
526535 }
527536
537+ /// Encodes a node to the current graph.
528538 fn encode_node (
529539 & mut self ,
530540 node : & NodeInfo ,
@@ -539,8 +549,14 @@ impl<D: Deps> EncoderState<D> {
539549 )
540550 }
541551
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.
542558 #[ inline]
543- fn promote_node (
559+ fn encode_promoted_node (
544560 & mut self ,
545561 prev_index : SerializedDepNodeIndex ,
546562 record_graph : & Option < Lock < DepGraphQuery > > ,
@@ -698,14 +714,16 @@ impl<D: Deps> GraphEncoder<D> {
698714 self . status . lock ( ) . as_mut ( ) . unwrap ( ) . encode_node ( & node, & self . record_graph )
699715 }
700716
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.
701719 #[ inline]
702- pub ( crate ) fn promote (
720+ pub ( crate ) fn send_promoted (
703721 & self ,
704722 prev_index : SerializedDepNodeIndex ,
705723 prev_index_to_index : & IndexVec < SerializedDepNodeIndex , Option < DepNodeIndex > > ,
706724 ) -> DepNodeIndex {
707725 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 (
709727 prev_index,
710728 & self . record_graph ,
711729 prev_index_to_index,
0 commit comments