Repository navigation
perf(dagql): avoid caching reflected primitive getters - #14806
Merged
Merged
Conversation
Reading a plain string, integer, float or boolean field is cheaper than publishing another cache result for the read. Use the existing uncached path for those reflected getters. Getter execution and normal tracing stay enabled. Object, optional, list and custom scalar fields keep their policy. A complete warm edited Go test listing improves 87.20s to 76.05s in a balanced comparison. Both versions return 4,399 rows and complete cleanup. The smaller nine-row control stays near one second. Engine CPU and allocation improve in the full listing; peak container memory is not lower in this cohort. Extend the field-policy fixture and add one behavioral test for values, tracing callbacks and repeated-read cache outcomes. The behavior test fails without the six-line policy. The full DagQL race suite passes. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
perf/reflected-scalar-getters
branch
from
October 23, 2026 09:40
d66e8a1 to
56af4a8
Compare
Scalar getters use DoNotCache to avoid cache overhead. This flag also makes the telemetry path emit a span for each call. Repeated reads of the same field produce duplicate spans and logs. Add a separate flag to keep span deduplication for these getters. Pass it from the field spec to the call request and preserve it when the request is cloned. Keep repeated traces for fields with an explicit DoNotCache policy. Keep the WithRepeatedTelemetry reset behavior. Test real field selections with core.AroundFunc. Check the span count, returned value, and absence of cache hits. Also check request clones and explicit cache policies. Signed-off-by: Tibor Vass <[email protected]>
tiborvass
marked this pull request as ready for review
October 27, 2026 14:33
tiborvass
approved these changes
Oct 27, 2026
This was referenced Oct 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was profiling Go test collection listing in dagger/dagger with wcprof. After discovering the tests, the engine still spent substantial time reading fields such as each dimension's name and key. Reading the field is cheap, but DagQL creates and keeps a separate cached result for it. That bookkeeping costs more than the read.
Use the existing uncached-call path for automatically generated getters of plain
String,Int,FloatandBooleanfields. These getters only read their immutable receiver. Each getter still runs and keeps its normal call tracing. The change adds six production lines and no cache, lock or shared state. Objects, lists, optional values, custom scalars and resolver functions retain their current behavior.Full Go collection listing
dagger check --module go --check test --list --allI compared the same development engine with and without these six lines. All eight measured commands returned the complete expected 5,199 rows, in order, and closed their sessions successfully.
That is 22% less elapsed time, 15% less engine CPU and 13% fewer allocated bytes. Every pair improves; no samples were discarded. Mean elapsed time also improves, 56.30 → 44.31 s.
The first two pairs were a screen; after both improved, I added two validation pairs. The order was before, after, after, before, before, after, after, before. Each command starts a fresh CLI after source and test edits. Each engine switch retained the same disk cache after graceful shutdown and completed an unprofiled preparation. Telemetry, ordinary GC and the eight-CPU / 40-GiB limits stayed unchanged. Profiling was off; output, cleanup, background-work and resource checks passed.
These numbers are conditional on a shared development stack, rather than plain main: engine
1e0512b6, based on maind5f68c6, includes #14802, #14738, #14808, experimental sharing of installed schemas, Dang #205 and common integration patches. Both versions use the same CLI (2b99fcb9, including the local stdout correctness fix) and Go moduleb3631f19(mainc25c457plus Go #68, including Erik's merged discovery changes). Only this PR differs between the engines; the new Dang callback optimization is excluded from both.The fixture is dagger/dagger
ff0b029a, root Go module withtest = ["."]: 800 package checks, 4,398 existing tests and one test added per measurement. This does not measure every nested module or a cold engine.Cost and correctness
The cost is repeating a struct-field read when the same field is requested again. A previous warmed-query probe with real
core.AroundFunctracing showed no slowdown from that repetition.Lower allocation does not guarantee a lower memory peak. Sampled engine peaks overlap: 11.94–13.32 GB before and 11.47–13.75 GB after. Two candidate peaks were higher than their paired controls.
The behavioral test reads all four scalar types twice, checks their values and verifies all eight tracing callbacks without cache hits. It fails without the change. The field-policy test covers object, list and optional fields. The full standalone DagQL race suite passes; the focused tests also pass on the exact combined engine above.
go test -race -count=1 ./dagqlTo exercise the listing workload in scratch checkouts, use dagger/dagger
ff0b029aand grouville/gob3631f19in sibling directoriesfixtureandgo-module. Put this infixture/dagger.toml:From
fixture, point the same CLI at each engine with_EXPERIMENTAL_DAGGER_RUNNER_HOST. Run a complete preparation, then time the listing command after edits todagql/types.goanddagql/cache_test.go. Verify complete output and successful exit. Keep engine resources, the Go checkout and the CLI identical. Absolute times depend on the engine stack and machine.