Skip to content

perf: faster module evaluation and collection listings - #15035

Merged
sipsma merged 24 commits into
mainfrom
sipsma/collection-receiver-once
Nov 2, 2026
Merged

sipsma merged 24 commits into
mainfrom
sipsma/collection-receiver-once

Conversation

@sipsma

@sipsma sipsma commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This PR makes evaluating module functions and collections faster, mostly by removing work that grew with a collection's size or with an engine's age. It also fixes two bugs found along the way: a restarted engine could throw away its whole cache, and a listing under a never-cached ancestor could fail.

The measuring workload was a listing of all 4,953 tests of this repository with the dagger/go module (dagger check --go --check test -l --all). On a fresh engine, the first four commits alone made that listing 2.2 times faster (76.3 → 35.4 s). Each change was measured on its own; see Measured.

Convert a collection once per session

Calling a function on one item of a module collection, such as get on one package of a Go module's packages, passes the whole collection to the module. The engine converted that collection into JSON for the module on every call. For a collection of N items, its N item calls did N² work, and each conversion queued on the dagql cache's lock. This made listing a large repository's tests slow on a fresh engine and after every edit.

  • Convert a receiver once per session. The converted form depends only on the receiver, the session and the active artifact view, not on the function called. The engine now converts each receiver once per session and view; later calls reuse it, and concurrent calls wait for the first. Modules receive exactly the same JSON as before.
  • Read a type's kind directly. Converting a value used to build its full type definition through dagql only to check whether it was a list, an object or a primitive: millions of cached calls when a function receives a large collection. Each module type now reports its kind itself.
  • Look up an attached result's ID under the cache's read lock. The lookup only reads the e-graph, like a cache hit, but took the write lock.

This helps any module function called many times on the same object, in every SDK.

Evaluate each module and each collection level once

  • One standalone server per module per client. Before it evaluates an artifact, the engine builds a standalone server for the artifact's module: a copy of the core schema with the module installed (dagqlServerForModule). It built a new one for every artifact, so a listing of this repository built 814 of them. Each new copy also re-checked every interface against every object type on its first cache hit, waiting on a mutex every copy shares. The server is now kept in the client's SchemaBuilderMemo, keyed the way the memo keys a builder for the same module set, so a client builds it once per module. Discovering a module's artifacts, decoding a persisted module tree, evaluating an artifact and running a check all share it, so every artifact evaluation does less work, not only listings: running checks and generators too, and dagger call on an artifact.
    • Sharing is safe. The server is built in the caller's client so that evaluation binds module provenance to results the caller's session owns (see the comment on Artifact.Evaluate), and that still holds. A built server is an immutable type registry, and it holds none of the dagql result cache. An artifact's view and a check's workspace are applied on each call's context, and module provenance is scoped per call through _implementationScoped.
    • A failed build isn't kept, so the next caller retries it. A caller waiting on another caller's build of the same server waits for that build to finish, even if its own context is cancelled. Module servers live until the client is released, like the memo's other entries.
  • Evaluate a collection's items from its listed receiver. When the engine expands collections, it reads keys level by level: a Go module collection gives package keys, and each package gives test keys. Each deeper level was evaluated by selecting its whole chain again from the module's root, about 3,400 ancestor selections per listing that the expansion had already evaluated. Each is a cache hit, but a persistable hit takes the cache's write lock. Now each expansion keeps the collection values it has evaluated, keyed by node, workspace and view, and starts each deeper evaluation from the nearest one. The values live only for that expansion, on the private copy of the node chain that Artifact.Evaluate already makes, never on returned or persisted trees. Running checks doesn't benefit, since the CLI evaluates each check in its own request.

The Dang SDK

It stops asking the engine for IDs it already has. It rebuilds each object the engine passes in from that object's ID, but didn't keep the ID. Returning or passing on such an object then cost one request back into the engine per value, which queued behind other calls' setup in a busy session. It now keeps the ID, but only a handle ID: a recipe ID is still resolved into a handle as before, so module return values pass the same checks.

It rebuilds each object a call receives once. Once item calls no longer queue on the cache, they run at the same time, and each one decoded the whole collection it received into Dang values. Every package entry in a Go module's collection holds the module it belongs to, so each call rebuilt hundreds of identical copies of it and evaluated each copy's body. With many calls overlapping, the engine's peak memory went up several times. Now the SDK decodes each distinct JSON value once, keeping it by content while a session that received it is open, and merges equal objects inside it. Each call still builds its own Dang values against its own engine client, but builds each distinct object once and shares it.

Core type definitions

A fresh engine built type definitions for its whole core API while initializing its first client: one TypeDef per core type, built from thousands of small cached calls. It built them again for each other API version it served, for example for a module pinned to an older engine version. That is about 0.37 s before the first client's first operation, plus another 0.13 s when such a module loads. Every first session on every fresh engine pays it, CI engines included. Now:

  • The core types are built concurrently. Each type's definition is independent of the others, so each is built on its own goroutine, and the schema's order is kept.
  • The definitions are built only when something first needs them: a module resolving a core type, or a caller listing the definitions. Forking a client's schema no longer builds them, so a client that loads no module and never asks for them, such as a plain query, skips the build entirely.
  • Resolved type references are reused within a build. The core schema names a few hundred distinct types (String!, [String!]!, Directory! and so on) thousands of times. A resolved reference is now reused for the rest of the build.
  • Each core function, and each object's list of functions, is built in one call. Two new hidden internal fields, __functionExact and __withFunctions, follow the existing __functionArgExact pattern. They replace a chain of one call per description, deprecation, argument and function. Like the other hidden fields, they don't appear in introspection or in generated SDKs.

The type definitions themselves don't change: same contents, same order.

Smaller fixed costs

  • The CLI writes a listing in a few large writes. Each write to a command's stdout becomes a telemetry log record, which the frontend stores, parses and replays. The listing's table writer wrote every cell and every run of padding separately, so a listing of a few thousand rows became tens of thousands of records. The listing is now buffered in every format, with a 32 KiB flush threshold, and split into writes only between lines. That way no write ends inside a multibyte character, since a log record's body must be valid UTF-8. The bytes written are unchanged.
  • A module's declared git clients are read once per tree. Every call of a module's functions reads the git clients its dagger.toml declares, to key the call. For a module loaded from git or a directory, each read was three cached calls on its tree. One listing of a large module's tests read them about 4,400 times, so about 13,000 cache calls. The tree is an immutable result, so the session now reads them once per tree and module directory. An edited dagger.toml makes a new tree, which gets its own read. A local module still reads its host on every call, since the file there can change.
  • Fetching a pinned image's metadata skips the initial HEAD. Reading the metadata of an image pinned by digest asked the registry for its root manifest twice: a HEAD to learn its type and size, then a GET for its content. The digest already names the root, so it is now fetched directly with a GET, checked against the digest, and its type read from its content. The request asks for every manifest and index type, since Distribution, the reference registry, refuses an OCI manifest or index whose type isn't asked for. On a fresh engine this saves one sequential round trip per pinned image, estimated from request timings at about 60 ms against Docker Hub from us-east-1 and about 300 ms through mirror.gcr.io. Tags still start with a HEAD, and resolving a ref to its digest is unchanged.

Long-lived engines

  • Reruns no longer get slower on an engine that stays up. Some calls get a new cache identity on every call or in every session, and end at one shared result. Address.container gives each call a new identity, and Container.from on an image tag one per session; both end at Container.from on the resolved digest. The cache records each caller's identity on that result as a new term, so a long-lived engine's shared results gather a term for every call that ever reached them. Two steps under the e-graph lock walked all of a result's terms on every teach and publish of such a call. termForResultByDigestLocked now looks the digest up in egraphTermsByTermDigest, which is kept exact wherever terms are created, repaired, removed, imported and compacted. Extra digests are recorded once on each of the result's output eq-classes, which hold the outputs of all its terms, instead of once per term. The identities themselves still accumulate until the cache prunes them; this change only stops their number from costing time on every call.
  • A restart keeps the cache for module objects with inline object fields. A clean engine restart could throw away the whole local cache: at the next start the engine rejected the saved cache, logged dagql persistence import failed; wiping and cold-starting, and started empty. This happened whenever the cache held a module object with another module object in one of its fields, for example a Go object with a collection field. The SDK sends such a field inline, as the inner object's fields, and the engine turns that field into its own result, which depends on the owning object. The owner was also recorded as depending on that result, so each depended on the other. And the owner's saved state pointed at the results inside the inline fields without depending on them. The engine checks both when it loads a saved cache, and either one made it reject the whole cache. Now the owner depends on the results its inline fields point to, and not on the result made from the field. A collection that is its own base is left out of the inline fields, as it already is in the object's own saved state; decoding sets it again.

Behavior changes

  • Dang: equal received objects are one object per call. Sharing one rebuilt object where a call used to rebuild each received copy changes three things a module could notice:

    • two received copies of an object with the same type and identical JSON, holding the same engine handle, now compare equal with ==, and uniq and contains treat them as one; the same goes for two inline-object arguments of the same type sent with identical JSON;
    • statements in a type's body besides declarations, such as a print or an API call, run once per call for equal copies instead of once per received copy;
    • other code in a type's body that runs on every rebuild does too: the initializer of a field that isn't sent with its object, such as one holding a function, and a nested type's static block.

    Fields that are sent keep their values and never re-run, and the module that sent the copies usually held one object, so the new answers match what it had.

  • Listings under a never-cached ancestor now work. Under an ancestor with +cache="never", every deeper receiver ran the ancestor again and looked up the listed key in the new result. When that run returned different keys, the listing failed with does not contain key "…" in the current subset. Items are now read from the execution whose keys were listed. The same applies when a TTL-cached ancestor expires during one expansion. For everything else, results are unchanged: within one request, re-selecting an ancestor returns the same cached result.

Measured

All on AWS m8gd.4xlarge machines (16 vCPU, arm64, 64 GB). Unless a line says otherwise, each run was on a freshly started engine, with the arms interleaved. Times are medians and differences are paired means with 95% intervals, so a difference isn't exactly the gap between medians. Every listing run listed exactly the tests go test -list finds. Each change was measured on a branch carrying the other pending listing changes, so absolute times are lower than on main.

Converting a collection once per session (the first four commits), 3 runs per arm. The base included the other pending listing improvements (#14953, #14934 and dagger/go#89) and the read-lock commit:

Listing Before After Difference
Fresh engine 76.3 s 35.4 s −41.4 s (−42.5 to −40.5)
After an edit and an added test 14.7 s 6.65 s −8.1 s (−8.4 to −7.9)
Unchanged 4.28 s 4.30 s no change

Engine CPU on the fresh listing went from 379 to 149 CPU-seconds. The read-lock commit alone saved 5.5 s of an 81 s fresh listing in a separate series; with the other commits applied, its effect on these listings is no longer measurable.

Peak engine memory, and rebuilding each received object once (commits 14 and 15). Letting the item calls run at once raised the fresh listing's peak memory to 5–14 GiB in these runs, and higher in others, varying with how many calls overlapped. Main peaks at about 4 GiB. Rebuilding each received object once brings it below main and also makes the listing faster. "Base" is main with the other pending listing improvements and commits 1 to 6. "main" includes the engine startup fix #14975 and runs an older dagger/go. 3 runs per arm:

Fresh listing Time Peak engine memory
main 108.3 s 3.7–3.9 GiB
base 25.4 s 5.3–13.5 GiB
base + commits 14 and 15 19.2 s 1.6–1.7 GiB
base, with a base image set in dagger/go 30.0 s 5.5–7.9 GiB
base + commits 14 and 15, with a base image set 23.5 s 1.4–1.5 GiB

With the base image set, the collection's objects hold an engine handle, the case where the merge changes equality. Commits 14 and 15 saved 6.3 s fresh with dagger/go's defaults (6.1 to 6.6 s) and 6.6 s with the base image set (6.5 to 6.6 s), and 0.3 s after an edit in both. The unchanged listing didn't change.

The other listing changes, each measured on its own:

Listing Dang SDK keeps IDs (6 pairs) Fewer stdout writes (6 pairs) Git clients once per tree (5 per arm) One server per module (5 pairs) Items from listed receiver (6 pairs) Core type definitions (10 pairs)
Fresh engine −1.00 s (−1.34 to −0.58) −0.32 s −0.39 s −0.30 s (−0.36 to −0.21) −0.10 s (−0.16 to −0.04) −0.42 s (−0.61 to −0.27)
After an edit and an added test −0.36 s −0.25 s −0.27 s (−0.30 to −0.23) −0.09 s (−0.11 to −0.06) no detectable change
Unchanged −0.31 s −0.27 s −0.28 s (−0.32 to −0.23) −0.10 s (−0.14 to −0.05) no detectable change

Resolving pinned images without the HEAD saved 0.35 s on the fresh listing, in 4 pairs. One server per module also cut engine CPU on each listing by 2.6 to 3.2 CPU-seconds, and items from the listed receiver made 3,416 fewer ancestor calls per listing and cut engine CPU by about 0.3 CPU-seconds. On a fresh engine, the first dagger query '{version}' went from 0.79–0.91 s to 0.42–0.44 s with the core type definitions changes, in 6 pairs. Building the definitions took about 0.50 s of the fresh listing before those changes and about 0.27 s after, so the build accounts for about 0.23 s of their 0.42 s. That series ran before a one-line fix, now folded into commit 24, that keeps __functionExact out of telemetry; the fix only removes work.

Long-lived engines, on a large Go test suite of 1,233 tests:

  • Reruns on one engine, with dagger check, measured with this change on a branch carrying this PR's other changes and other pending ones: each arm ran a fresh engine, one full run, then 8 unchanged reruns, on two machines. Without the change, reruns 1 to 8 took 22.3 → 60.9 s and 21.8 → 43.8 s, +5.50 and +3.15 s per rerun. With it, 18.7 → 19.6 s and 18.6 → 19.3 s, +0.11 and +0.09 s per rerun. The first unchanged rerun was also faster, 18.7 against 22.3 s and 18.6 against 21.8 s, since the terms pile up within one run too. Full runs on a fresh engine took about the same.
  • Restarts: one sequence per build, each on its own machine: a fresh run, two unchanged reruns, a clean docker stop -t 120 and docker start of the same engine, then unchanged runs. Every run passed all 1,233 tests. On main with the engine startup fix engine-dev: retry enabling cgroup controllers when a client connects during startup #14975, none of the cached results survived the restart, and the first run after it took 281.6 s, against 38.6 s for the last rerun before it. With this fix added, all 15,698 cached results came back, and that run took 31.3 s, against 35.0 s.

Tests

  • Receiver conversion: unit tests check that a second call in a session reuses the converted receiver, that another session converts its own, and that each artifact view gets its own filtered JSON; each fails without its change.
  • dagql: one new subtest fails with the old write lock, and another checks that lookups stay correct during concurrent merges under the race detector. dagql/cache_session_history_test.go times 100 sessions whose calls all reach one shared result, on a new cache and after 10,300 earlier sessions, and fails if the later batch is 3 times slower or more: without the change, 5.2 ms against 251.9 ms; with it, 3.4 ms against 3.4 ms.
  • Dang SDK: a received handle ID is handed back without any request to the engine, and a recipe ID still requires one. Equal received objects are merged and look-alike values aren't, a shared object is rebuilt once per call, the equality answer is pinned, and two calls sharing one decoded value each get their own client and objects.
  • CLI: a listing reaches stdout in a few writes with unchanged bytes, and no write ends inside a multibyte character.
  • Git clients: a git or directory module's declarations are read once per tree in a session, while another module in the same tree, an edited dagger.toml and another session each get their own read, and a failed read is retried.
  • Resolver: a pinned image's manifests are each requested once, with no HEAD, while a tag still starts with one; a pinned index which leaves out its own media type still resolves and pulls; and a registry answering a pinned ref with other content fails the resolve. The test registry refuses a manifest whose type isn't asked for, as Distribution does.
  • Module servers: TestModuleServerSharedPerModule checks that a client gets the same server for the same module, another module gets its own, servers hold no cache rows, and with no memo every call builds a new server. It fails without its change.
  • Listed receiver: TestCollections/TestNestedItemsFromListedReceiver lists items under a never-cached ancestor. It fails with the does not contain key error without its change.
  • Restart: a new test in core/integration/engine_persistence_test.go runs a module object holding an inline object and a list of them, restarts the engine, and expects the cached result back. It fails on main with the import error, and runs in the test-split/test-cache-persistence check. The unit tests in core/object_test.go now check what an inline field's owner depends on, including a collection that is its own base.

sipsma added 24 commits November 2, 2026 18:37
Attaching a result whose call frame references inline calls resolves each
referenced call to its attached result ID through resultIDForCall. That
lookup only reads the e-graph, with the same lookupMatchForCallLocked a
cache-hit lookup runs under the read lock, but it took egraphMu for
writing. Converting a module object for a function call attaches every
inline object it holds, so concurrent calls on a collection's items queued
on this one lock: in a fresh listing of dagger/dagger's tests, 685 of the
715 collection getters in flight were waiting there.

Take egraphMu for reading instead, through wcprof so a blocked acquisition
is recorded like the other egraph lock waits.

Signed-off-by: Erik Sipsma <[email protected]>
Converting a value for a module function asked each value's ModType for
its TypeDef only to read the kind. That builds the typedef through dagql
selections for every value converted, list elements included: millions
of cached calls when a function receives a large collection.

Every ModType already knows its kind, so expose it as Kind and switch on
that in the SDK input conversion and in attaching stored field values.

Signed-off-by: Erik Sipsma <[email protected]>
Every module function call converted its receiver for the SDK. A call on
one collection item receives the whole collection, so the calls on one
collection converted every item once per call: work quadratic in the
collection's size. Each conversion also attached every inline stored
object to the cache under the e-graph write lock, so concurrent item
calls queued behind each other.

The converted receiver depends only on the receiver result and the
active result scope, not on the function called. Memoize its JSON per
session, receiver result and artifact view through the cache's arbitrary
values, so concurrent calls wait on the first conversion. The session is
part of the key because conversion attaches inline objects to it.

Signed-off-by: Erik Sipsma <[email protected]>
The Dang SDK rebuilds each object the engine passes in as a node(id:)
handle, but didn't record that ID. Returning or passing on such an
object then sent node(id:){id} to learn the ID it started from: one
HTTP request into the engine per value, queued behind other nested
clients' setup in a busy session.

The engine scopes the objects it passes in before encoding them, so
that query only ever hands back the same ID. Record it on the handle,
as Dang's own ID loader does.

Signed-off-by: Erik Sipsma <[email protected]>
A module can receive a recipe ID, e.g. for an argument whose result was
released. node(id:) evaluates a recipe into a handle, and returning that
handle is what the module did before; returning the recipe instead sends
it through the replay check for module return IDs, which can refuse it.

Signed-off-by: Erik Sipsma <[email protected]>
A command's stdout emits each write as a telemetry log record, which the
frontend stores, parses through a virtual terminal and finally replays to
the real stdout one record at a time. The listing's table goes through
text/tabwriter, which writes every cell and every 8 bytes of padding
separately, so a listing of a few thousand rows became tens of thousands
of records. Buffer the listing, in every format, so it reaches stdout in
32 KiB writes. The bytes written are unchanged.

Signed-off-by: Erik Sipsma <[email protected]>
A log record's body must be valid UTF-8, or the OTLP exporter's protobuf
encoding rejects the whole batch. A fixed-size buffer can cut inside a
multibyte character in a description, so pass the listing on in pieces of
whole lines instead.

Signed-off-by: Erik Sipsma <[email protected]>
Every call of a module's functions reads the git clients its governing
dagger.toml declares, to key the call. For a module loaded from git or a
directory that is three cached calls on its tree, which a persistable
hit runs under the cache's write lock: about 4,400 times in one listing
of a large module's tests.

The tree is an immutable result, so the session now reads them once per
tree result and module directory. A tree with an edited dagger.toml is
another result, and result IDs are never reused. A local module still
reads its host on every call, since the file there can change.

Signed-off-by: Erik Sipsma <[email protected]>
Resolving an image pinned by digest asked the registry for its root
manifest twice: a HEAD to learn its type and size, then a GET for its
content. The digest already names the root, and the GET follows either
way, so the HEAD only adds a round trip. On a fresh engine that's one of
the four sequential requests a resolve makes: about 60 ms against Docker
Hub from us-east-1, and about 300 ms through mirror.gcr.io.

A pinned ref's root is now fetched directly, checked against the digest,
and served from memory when the image's metadata is read. Its type is
read from its content, as for a root already in the content store. Tags
still start with a HEAD, which is all a later resolve needs when the tag
still names local content, and which Docker Hub doesn't count against
its pull limit.

Signed-off-by: Erik Sipsma <[email protected]>
containerd's fetcher asks only for the media type it's given, and the
pinned root is fetched before its type is known. Distribution refuses an
OCI manifest or index whose own type isn't in the request's Accept
header, wildcard or not, so a digest naming an OCI manifest failed to
resolve. The root's download now asks for every manifest and index type,
as containerd's resolver does when it resolves a ref.

The test registry now refuses a manifest whose type isn't asked for, as
Distribution does.

Signed-off-by: Erik Sipsma <[email protected]>
A call on one collection item receives the whole collection. When every
item holds the same object, such as the module it belongs to, the SDK
decoded and rebuilt that object once per item, on every call: dagger/go's
package collection sent 609 copies of its GoModule, each holding a Go, to
each of its 608 item calls. Rebuilding an object evaluates its type's
class body, which for those two types is over a hundred members. Calls
running at once each held their own decoded copy of the collection.

Decode a call's parent and arguments once, keeping the decoded value by
its JSON's content while a session that received it is open, and merge
equal objects inside it into one. Each call then rebuilds each distinct
object once and shares it wherever it occurs, as the module's own value
did before it was sent. Only plain decoded data is kept between calls:
each call builds its own Dang values against its own engine client.

Signed-off-by: Erik Sipsma <[email protected]>
Two received copies of an object holding the same handle are now one
object, so they compare equal; before, each copy got its own handle
value and Dang compares handles by identity. Pin that answer. Also check
that calls sharing one decoded value each build their own Dang values
against their own engine client.

Say that decoded values are shared by content across sessions too, not
only within one.

Signed-off-by: Erik Sipsma <[email protected]>
Every artifact a client discovers, evaluates or checks got a standalone
dagql server of its own: a fork of the core schema with the module
installed again. A listing evaluates each collection receiver this way,
so dagger/dagger's listing forked the core schema 814 times, and the
first cache hit on each fork re-checked every interface against every
object type, queueing on the interfaces' shared mutex.

The fork exists so evaluation binds module provenance to results the
caller's session owns. It never isolated one artifact from another: a
built server is an immutable type registry, and what a call depends on,
such as its view or workspace, is on the call's context. Keep the server
in the client's schema builder memo, keyed like the builder of the same
module set, so a client builds it once per module. A failed build is not
kept.

Signed-off-by: Erik Sipsma <[email protected]>
Expanding a collection evaluated each deeper receiver by selecting its
whole chain again from the module root. A listing of dagger/go's tests
re-selected about 3,400 ancestors that the expansion had already
evaluated, each a cache hit that takes the cache's write lock.

An expansion now keeps the receivers it evaluated, per workspace and
view, and starts each deeper evaluation from the nearest one.

This also fixes listings under a never-cached ancestor. Each deeper
receiver used to run the ancestor again and look up the listed key in
the new result. When that run returned different keys, the listing
failed with "does not contain key ... in the current subset". Items are
now read from the execution whose keys were listed.

Signed-off-by: Erik Sipsma <[email protected]>
A session-scoped call, such as Container.from on a tag, gets a new recipe
in every session and returns a result every session shares, such as
Container.from on the resolved digest. Teaching each session's recipe
onto that shared result adds a term to it, so a long-lived engine's
shared results gather a term for every session that ever reached them.

Two steps of teaching and indexing walked all of a result's terms under
the e-graph lock: finding the result's term with a given digest, and
recording the request's extra digests on its output eq-classes. On one
engine, each unchanged rerun of a 1,233-test suite added about 2,600
terms to one image's result, and planning's calls queued longer on the
lock every rerun.

Find the result's term through the term-digest index, and record extra
digests on the result's output eq-classes, which hold the outputs of all
its terms, instead of once per term.

Signed-off-by: Erik Sipsma <[email protected]>
When a module object's field holds another module object, the field
keeps that object inline, as its fields, and the object becomes its own
result: a field call on its owner, which depends on the owner. The owner
recorded that result as its own dependency, so each depended on the
other, and the owner's persisted state referred to the results inside
the inline fields without depending on them. A restarted engine refuses
a persisted cache with either, so it discarded the whole cache and
started cold. A large module's test runs hit this on every engine restart.

The owner now depends on the results its inline fields refer to, and
not on the object made from them. A collection base that is the object
itself stays out of the inline fields, as it does in the object's own
persisted state: decoding sets it again.

Signed-off-by: Erik Sipsma <[email protected]>
The owner of an inline object field now depends on the results the
inline fields refer to, not on the object made from them. The unit
tests now check that: no dependency for a field holding no results,
the handle and the collection base a field holds, and no base for an
inline collection that is its own base, which decoding sets again.

Signed-off-by: Erik Sipsma <[email protected]>
A fresh engine builds the core API's type definitions for each view it
serves: once when its first client connects, and again for a module's
own engine version. Each build ran every type's dagql selects one after
another, about 0.37 s and 0.13 s on a fresh listing of dagger/dagger's
tests. Every type's definition is independent of the others, so build
them on their own goroutines and keep the schema's order.

Signed-off-by: Erik Sipsma <[email protected]>
A client's schema is a fork of the core view's server; the view's type
definitions are only needed when a module resolves core types or lists
them. Building them with the server put thousands of selects on every
fresh engine's first client initialization (about 0.37 s on a fresh
listing of dagger/dagger's tests). Build them on first use instead.

Signed-off-by: Erik Sipsma <[email protected]>
The core schema's fields and arguments name a few hundred distinct types
(String!, [String!]!, Directory!, ...) thousands of times, and building
the core type definitions resolved every one of them again, through
several selects each, and more for lists and for arguments with an
@expectedType. Keep each resolved reference, with an argument's
@expectedType, for the rest of the build and reuse it.

Signed-off-by: Erik Sipsma <[email protected]>
Building the core type definitions created each function with one
select and then set its description, its deprecation and each argument
with one more, and added each function to its object with another:
about 4,300 selects for the core schema, each a new cache entry. Add
__functionExact and __withFunctions, which take the whole function and
the whole function list, so each core function and each object's
function list is one select.

Signed-off-by: Erik Sipsma <[email protected]>
@grouville
grouville self-requested a review November 2, 2026 19:59
@sipsma
sipsma merged commit 560479e into main Nov 2, 2026
93 checks passed
@sipsma
sipsma deleted the sipsma/collection-receiver-once branch November 2, 2026 20:02
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.

2 participants