Skip to content

Commit 91971f2

Browse files
committed
Improve tracing logging
1 parent 3da5768 commit 91971f2

File tree

3 files changed

+17
-43
lines changed

3 files changed

+17
-43
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

+14-39
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ impl<K: DepKind> DepGraph<K> {
598598
}
599599
}
600600

601+
#[instrument(skip(self, tcx, data, parent_dep_node_index), level = "debug")]
601602
fn try_mark_parent_green<Ctxt: QueryContext<DepKind = K>>(
602603
&self,
603604
tcx: Ctxt,
@@ -613,22 +614,15 @@ impl<K: DepKind> DepGraph<K> {
613614
// This dependency has been marked as green before, we are
614615
// still fine and can continue with checking the other
615616
// dependencies.
616-
debug!(
617-
"try_mark_previous_green({:?}) --- found dependency {:?} to \
618-
be immediately green",
619-
dep_node, dep_dep_node,
620-
);
617+
debug!("dependency {dep_dep_node:?} was immediately green");
621618
return Some(());
622619
}
623620
Some(DepNodeColor::Red) => {
624621
// We found a dependency the value of which has changed
625622
// compared to the previous compilation session. We cannot
626623
// mark the DepNode as green and also don't need to bother
627624
// with checking any of the other dependencies.
628-
debug!(
629-
"try_mark_previous_green({:?}) - END - dependency {:?} was immediately red",
630-
dep_node, dep_dep_node,
631-
);
625+
debug!("dependency {dep_dep_node:?} was immediately red");
632626
return None;
633627
}
634628
None => {}
@@ -638,51 +632,36 @@ impl<K: DepKind> DepGraph<K> {
638632
// an eval_always node, let's try to mark it green recursively.
639633
if !tcx.dep_context().is_eval_always(dep_dep_node.kind) {
640634
debug!(
641-
"try_mark_previous_green({:?}) --- state of dependency {:?} ({}) \
642-
is unknown, trying to mark it green",
643-
dep_node, dep_dep_node, dep_dep_node.hash,
635+
"state of dependency {:?} ({}) is unknown, trying to mark it green",
636+
dep_dep_node, dep_dep_node.hash,
644637
);
645638

646639
let node_index =
647640
self.try_mark_previous_green(tcx, data, parent_dep_node_index, dep_dep_node);
641+
648642
if node_index.is_some() {
649-
debug!(
650-
"try_mark_previous_green({:?}) --- managed to MARK dependency {:?} as green",
651-
dep_node, dep_dep_node
652-
);
643+
debug!("managed to MARK dependency {dep_dep_node:?} as green",);
653644
return Some(());
654645
}
655646
}
656647

657648
// We failed to mark it green, so we try to force the query.
658-
debug!(
659-
"try_mark_previous_green({:?}) --- trying to force dependency {:?}",
660-
dep_node, dep_dep_node
661-
);
649+
debug!("trying to force dependency {dep_dep_node:?}");
662650
if !tcx.dep_context().try_force_from_dep_node(*dep_dep_node) {
663651
// The DepNode could not be forced.
664-
debug!(
665-
"try_mark_previous_green({:?}) - END - dependency {:?} could not be forced",
666-
dep_node, dep_dep_node
667-
);
652+
debug!("dependency {dep_dep_node:?} could not be forced");
668653
return None;
669654
}
670655

671656
let dep_dep_node_color = data.colors.get(parent_dep_node_index);
672657

673658
match dep_dep_node_color {
674659
Some(DepNodeColor::Green(_)) => {
675-
debug!(
676-
"try_mark_previous_green({:?}) --- managed to FORCE dependency {:?} to green",
677-
dep_node, dep_dep_node
678-
);
660+
debug!("managed to FORCE dependency {dep_dep_node:?} to green");
679661
return Some(());
680662
}
681663
Some(DepNodeColor::Red) => {
682-
debug!(
683-
"try_mark_previous_green({:?}) - END - dependency {:?} was red after forcing",
684-
dep_node, dep_dep_node
685-
);
664+
debug!("dependency {dep_dep_node:?} was red after forcing",);
686665
return None;
687666
}
688667
None => {}
@@ -702,23 +681,19 @@ impl<K: DepKind> DepGraph<K> {
702681
// invalid state will not be persisted to the
703682
// incremental compilation cache because of
704683
// compilation errors being present.
705-
debug!(
706-
"try_mark_previous_green({:?}) - END - dependency {:?} resulted in compilation error",
707-
dep_node, dep_dep_node
708-
);
684+
debug!("dependency {dep_dep_node:?} resulted in compilation error",);
709685
return None;
710686
}
711687

712688
/// Try to mark a dep-node which existed in the previous compilation session as green.
689+
#[instrument(skip(self, tcx, data, prev_dep_node_index), level = "debug")]
713690
fn try_mark_previous_green<Ctxt: QueryContext<DepKind = K>>(
714691
&self,
715692
tcx: Ctxt,
716693
data: &DepGraphData<K>,
717694
prev_dep_node_index: SerializedDepNodeIndex,
718695
dep_node: &DepNode<K>,
719696
) -> Option<DepNodeIndex> {
720-
debug!("try_mark_previous_green({:?}) - BEGIN", dep_node);
721-
722697
#[cfg(not(parallel_compiler))]
723698
{
724699
debug_assert!(!self.dep_node_exists(dep_node));
@@ -772,7 +747,7 @@ impl<K: DepKind> DepGraph<K> {
772747
// Multiple threads can all write the same color here
773748
data.colors.insert(prev_dep_node_index, DepNodeColor::Green(dep_node_index));
774749

775-
debug!("try_mark_previous_green({:?}) - END - successfully marked as green", dep_node);
750+
debug!("successfully marked {dep_node:?} as green");
776751
Some(dep_node_index)
777752
}
778753

compiler/rustc_query_system/src/dep_graph/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ pub trait DepContext: Copy {
5252
}
5353

5454
/// Try to force a dep node to execute and see if it's green.
55+
#[instrument(skip(self), level = "debug")]
5556
fn try_force_from_dep_node(self, dep_node: DepNode<Self::DepKind>) -> bool {
56-
debug!("try_force_from_dep_node({:?}) --- trying to force", dep_node);
57-
5857
let cb = self.dep_kind_info(dep_node.kind);
5958
if let Some(f) = cb.force_from_dep_node {
6059
f(self, dep_node);

compiler/rustc_query_system/src/query/plumbing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,7 @@ where
563563
Some((result, dep_node_index))
564564
}
565565

566+
#[instrument(skip(tcx, result, query), level = "debug")]
566567
fn incremental_verify_ich<CTX, K, V: Debug>(
567568
tcx: CTX::DepContext,
568569
result: &V,
@@ -577,12 +578,11 @@ fn incremental_verify_ich<CTX, K, V: Debug>(
577578
dep_node,
578579
);
579580

580-
debug!("BEGIN verify_ich({:?})", dep_node);
581581
let new_hash = query.hash_result.map_or(Fingerprint::ZERO, |f| {
582582
tcx.with_stable_hashing_context(|mut hcx| f(&mut hcx, result))
583583
});
584+
584585
let old_hash = tcx.dep_graph().prev_fingerprint_of(dep_node);
585-
debug!("END verify_ich({:?})", dep_node);
586586

587587
if Some(new_hash) != old_hash {
588588
incremental_verify_ich_failed(

0 commit comments

Comments
 (0)