fix(workflows): avoid cloning payloads for graph updates - #1
Conversation
|
Thanks @ashkanvg — this is a good catch, and it's the right complement to @Shreyasd10's work. bastani-inc#2138 made painting topology-bounded; you found that the store was still payload-bound before the renderer ever ran, which is the half that a 100 MiB workflow input actually hits. Heads-up on where this is landing. Both changes are now combined on a branch in the upstream repository, bastani-inc/atomic#2143, as two commits: Both keep their original authors, so GitHub attributes each commit to whoever wrote it, and bastani-inc#2143 credits you both in the description. Your commit needed rebasing onto current
let currentSnapshot = store.snapshot();
…
unsubscribe = store.subscribe((snapshot) => { currentSnapshot = snapshot; … });Swapping in const selectRows = () => {
const snapshot = readGraphStoreSnapshot(store);
const resumeCandidateLookup = intent === "resume" ? resumeCandidateCache(snapshot) : undefined;
return selectRunsForPicker(snapshot.runs, state.query, state.includeAll, Date.now(), intent, resumeCandidateLookup);
};
unsubscribe = subscribeStoreInvalidation(store, () => tui.requestRender?.());That keeps the payload-free path — I'm reviewing your commit properly next; this comment is only about the merge mechanics. Please follow along on bastani-inc#2143. |
|
@ashkanvg — your commit has been through the same adversarial review @Shreyasd10's got, run against your layer alone. Full report on #2144. It holds up: render output is byte-identical between the legacy snapshot and your compact projection across every migrated consumer, and memoization freshness held at 31 checkpoints across every mutating store method with zero stale reads. One thing was falsified, and I think you'll find it interesting: The projection was not actually payload-free. That is worse here than at an ordinary truncation site, precisely because of the thing that makes your change fast: Fixed in Related, not fixed, and not yours: Two other things worth your attention before merge, both in the review:
And I confirmed your fixture change to Nice work. The SlicedString thing is genuinely subtle and I doubt many reviewers would have caught it by eye. |
|
Shipped. @ashkanvg — your commit is on It merged with a merge commit rather than a squash specifically so that stays true — Two things came out of your change that are worth knowing. Your patch surfaced a real memory leak, and not the one you were fixing. Chasing it turned up the same shape in two places on the durable path that predate all of this: Your fixture change was a repair, not an accommodation, and it is now on the record as such. The edit to One note on attribution: that fixture repair had to move down into bastani-inc#2143, because the layer that breaks a test has to be the layer that fixes it or the lower PR is red on its own. It is unchanged and co-authored to you on that commit. Thanks — the 147 ms → 2.85 ms measurement on a real 480-node graph with a 100 MiB input is what made the case, and the half you found was genuinely invisible from the rendering side. |
Summary
Companion patch for bastani-inc/atomic#2138.
PR bastani-inc#2138 makes large graph painting topology-bounded by clipping cards/edges to the viewport, retaining layout identity, and skipping idle animation frames. While testing that branch with payload-heavy nested workflows, I found a separate bottleneck before rendering: every store mutation still built a full
JSON.stringify/JSON.parsesnapshot, so a small question/status update traversed complete workflow inputs, results, child outputs, and tool bodies before bastani-inc#2138's optimized renderer ran.This patch keeps bastani-inc#2138's viewport, topology, and animation implementation intact and makes its store observation payload-independent.
What changed
Store.snapshot()/Store.subscribe(snapshot)contract for compatibility. The opt-in full status-file writer intentionally remains on that path because its external JSON schema is unchanged.Before / after
Exact bastani-inc#2138 head versus this stacked commit, using the same dependencies and a real
GraphViewwith 480 nodes plus a 100 MiB workflow input:9505c1ba)bastani-inc#2138 already fixes topology-scaled rendering; this patch removes the remaining payload-scaled mutation cost.
Tests
npm run check— Biome, TypeScript, and shrinkwrap pass.npm run test:unit— 613 files, 5,719 passed, 2 skipped.npm run test:integration— 35 files passed, 1 skipped; 484 passed, 1 skipped.npm run test:ci-contracts— 5 files, 38 passed.Notes
fix/2100-overlay-graph-tui-perfbefore fix(workflows): keep overlay graph TUI responsive for large stage graphs bastani-inc/atomic#2138 lands.