Skip to content

dagql: add a result's dependency edges at once - #14966

Closed
sipsma wants to merge 2 commits into
mainfrom
sipsma/dagql-batch-dependency-edges
Closed

sipsma wants to merge 2 commits into
mainfrom
sipsma/dagql-batch-dependency-edges

Conversation

@sipsma

@sipsma sipsma commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Publishing a result whose value attaches many dependencies was quadratic in their number. Each dependency edge took the egraph lock on its own and recomputed the parent's required session resources over every dependency added so far. A container with a mounted file per imported package, such as a Go link step with ~1,400 package archives from withMountedFiles, pays that on every result built from it.

This adds all of a result's edges under one lock and recomputes its required set once. Publication's attached dependencies, PartHost.AddDependencies and decoded dependencies on import all take the batched path. Edges, ownership counts and owned dependencies' install spans are unchanged. If any dependency was already collected, the whole batch is now refused before any edge is added.

Measured, for one publish of a result with N plain dependencies:

N 100 400 1,400 2,800
Before 0.56 ms 3.2 ms 27.5 ms 109 ms
After 0.39 ms 1.5 ms 6.4 ms 16 ms

On an edit build of dagger's CLI with a Go module that mounts each package archive, the edit of the CLI's own package was 0.16 s faster (95% interval −0.30 to −0.01 s, 12 interleaved runs per arm). The other builds' changes weren't distinguishable from noise.

The second commit makes the existing test fail without the change: the result's required set must change once, not once per dependency carrying a session resource.

@sipsma
sipsma force-pushed the sipsma/dagql-batch-dependency-edges branch from 5e84d65 to 4e6b17e Compare October 30, 2026 19:01
…red set once

Publishing a result whose value attaches many dependencies, such as a
container with a mounted file per imported package, added each edge in
its own egraph critical section and recomputed the parent's required
session resources over all its deps after each one, quadratic in the
number of deps. Add them all under one lock and recompute once.

Signed-off-by: Erik Sipsma <[email protected]>
…s deps

The attached-dependencies test only checked the required set's contents,
which the per-edge recompute also got right. Check that publishing the
result changes its required set once, not once per dep that has session
resources.

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

sipsma commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Folded unchanged into #15007, the engine performance batch; continuing there.

@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