Skip to content

dagql: removing a result doesn't start a new frame generation - #14985

Closed
sipsma wants to merge 2 commits into
mainfrom
sipsma/dagql-removal-keeps-frame-generation
Closed

sipsma wants to merge 2 commits into
mainfrom
sipsma/dagql-removal-keeps-frame-generation

Conversation

@sipsma

@sipsma sipsma commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Every time a session ended, the dagql cache threw away the memos keyed on its frame generation, because removing a result counted as replacing its frame. So the module-dependency memo from #14920 never survived from one build to the next. This change stops removal from starting a new generation.

Why

Cache.ModuleResultIDs keeps each frame's answer for the frame generation it was computed in. Replacing any result's frame starts a new generation, since an equivalent replacement can reference different Module results. removeResultFromEgraphLocked cleared a removed result's frame with storeResultCall(nil), and that counted as a replacement. A session's release removes hundreds of results, mostly module type definitions that each session rebuilds, so every build ended with all memos stale.

Here are the generations started per build, counted per call site on a per-package Go build of dagger's CLI with dagger/go (one c8gd.4xlarge, fresh engine):

Build Generations started From removals
Unchanged rebuild 429 429
Edit ~655 ~630

On each edit, ~8,500 frames found a stale memo and recomputed.

How

A removed result's ID is never registered again. So no resultCallByResultID lookup can reach another frame under it, and the answers memoized while it was registered still hold. Removal now clears the frame with dropResultCall, which starts no generation. Clearing the frame of a result that stays registered, as stored-value pruning does, still starts one, since that row can later get a new frame.

There is one behavior change. A frame held outside the cache, whose graph references a removed result by ID, now gets its memoized answer where a fresh walk would fail. A live root keeps the results it references through dependency edges, so ModDepsForCall doesn't reach this case.

Effect

After the change, an unchanged rebuild starts no generations and an edit ~22. Those ~22 are real replacements: content digests taught to directories, and frames stored on results that aren't in the cache yet.

Build times don't change, because the memo is cheap: 0.1 ms per unchanged rebuild, and 60–110 ms per edit summed over ~3,300 calls that run in parallel. Medians in seconds, 4 runs per arm in alternating order, one c8gd.4xlarge, a fresh engine per run:

Build Before After
First build 22.87 22.93
Unchanged rebuild 0.86 0.86
Edit of a dependency package 7.06 7.11
Edit of the CLI's own package 5.58 5.53

Each difference is inside its 95% interval around zero.

Testing

TestModuleResultIDsSurviveResultRemoval releases a session, checks that its result was removed and its frame cleared, and checks that a memo computed before the release is served without recomputing. Without the change, it recomputes 3 frames and fails.

@sipsma
sipsma force-pushed the sipsma/dagql-removal-keeps-frame-generation branch from 41431cb to fe95854 Compare October 30, 2026 19:02
ModuleResultIDs memoizes each frame's answer for the frame generation it was
computed in, and every frame replacement starts a new generation. Removing a
result from the cache counted as one, since it stores a nil frame. A session's
release removes hundreds of results, so on a per-package Go build every memo
went stale between builds: about 430 removals per unchanged rebuild of
dagger's CLI and 630 per edit, against about 20 real replacements.

A removed result's ID is never registered again, so no lookup can reach
another frame under it, and the answers memoized while it was registered
still hold. Removal now clears the frame without starting a generation.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma

sipsma commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #15007, which carries these commits unchanged.

@sipsma sipsma closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant