tamer: asg: Reduce Debug output of `Asg` and `AirAggregateCtx`

The ASG had its output reduced previously but I had apparently stashed it; I
found it while trying to clean up after so many failed or partial attempts
and the various scoping changes.

The most fundamental issue is that there's too much information: it's very
difficult to interrogate so I seldom look at it, and it slows down Parser
trace output to the point where it's useless on even one of our smallest
systems, generating 1.5GiB of output for a graph of ~10k
objects (via tameld).

DEV-13162
main
Mike Gerwitz 2023-05-23 16:15:38 -04:00
parent ac9b7f620e
commit 19a5ec1e0f
2 changed files with 35 additions and 2 deletions

View File

@ -450,7 +450,7 @@ impl AirAggregate {
/// Additional parser context,
/// including the ASG and parser stack frames.
#[derive(Debug, Default)]
#[derive(Default)]
pub struct AirAggregateCtx {
/// The ASG under construction by this parser.
///
@ -478,6 +478,19 @@ pub struct AirAggregateCtx {
index: ScopeIndex,
}
impl Debug for AirAggregateCtx {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// The index provides far too much information to be useful,
// and slows down Parser trace generation.
f.debug_struct("AirAggregateCtx")
.field("asg", &self.asg)
.field("stack", &self.stack)
.field("ooi_pkg", &self.ooi_pkg)
.field("index.len()", &self.index.len())
.finish_non_exhaustive()
}
}
/// Object scope index at a given environment.
type ScopeIndex = FxHashMap<
(ObjectRelTy, SymbolId, ObjectIndex<Object>),

View File

@ -83,7 +83,6 @@ type Ix = global::ProgSymSize;
///
/// For more information,
/// see the [module-level documentation][self].
#[derive(Debug)]
pub struct Asg {
/// Directed graph on which objects are stored.
graph: DiGraph<Node, AsgEdge, Ix>,
@ -99,6 +98,27 @@ impl Default for Asg {
}
}
impl Debug for Asg {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
// The ASG provides far too much information even on modestly size
// tests,
// letalone real-world graphs with tens to hundreds of thousands
// of nodes and edges.
// Outputting the graph also brings Parser trace generation to a
// crawl,
// making tracing half-useless.
// So this provides a simple summary.
// If we need a graph representation,
// a visualization or ability to query it is far more appropriate.
write!(
f,
"[ASG: {} objects, {} edges]",
self.object_count(),
self.graph.edge_count(),
)
}
}
impl Asg {
/// Create a new ASG.
///