perf(trace): share row-wise node outputs with the trace when nothing can alias them

This commit is contained in:
Stefan
2026-11-19 11:30:06 +01:00
parent 03a64e3abf
commit cd028e715b
2 changed files with 13 additions and 6 deletions
@@ -498,7 +498,9 @@ impl Plan {
shared: plain && CompiledGraph::flat_scalars(columns),
},
};
Box::new(super::PlanTrace::new(graph.steps.len(), source, lazy))
let mut trace = super::PlanTrace::new(graph.steps.len(), source, lazy);
trace.aliased = overlapping;
Box::new(trace)
}),
};
run.walk(root.clone()).await;
@@ -59,6 +59,7 @@ pub(crate) struct PlanTrace<'a> {
values: Vec<Option<Rc<Data<'a>>>>,
pub(crate) source: Source<'a>,
lazy: bool,
pub(crate) aliased: bool,
pub(crate) refused: Option<&'static str>,
}
@@ -73,6 +74,7 @@ impl<'a> PlanTrace<'a> {
values: vec![None; slots],
source,
lazy,
aliased: true,
refused: None,
}
}
@@ -196,11 +198,14 @@ impl<'a> Run<'_, 'a> {
if let Some(trace) = self.trace.as_mut() {
trace.hosted.push(Hosted {
node,
values: output
.materialized()
.iter()
.map(Variable::deep_clone)
.collect(),
values: match trace.aliased {
true => output
.materialized()
.iter()
.map(Variable::deep_clone)
.collect(),
false => output.materialized(),
},
kernel,
walked,
});