Repository navigation
perf(dagql): share result lists when restoring the cache - #14730
Merged
grouville merged 2 commits intoOct 27, 2026
Merged
Conversation
grouville
force-pushed
the
pr/go-collections-restored-index
branch
2 times, most recently
from
October 19, 2026 19:30
5a66952 to
576077e
Compare
grouville
force-pushed
the
pr/go-collections-restored-index
branch
from
October 21, 2026 22:20
576077e to
009630f
Compare
grouville
force-pushed
the
pr/go-collections-restored-index
branch
from
October 22, 2026 04:08
009630f to
ba2776d
Compare
This was referenced Oct 22, 2026
grouville
force-pushed
the
pr/go-collections-restored-index
branch
from
October 23, 2026 11:30
ba2776d to
9253cb9
Compare
grouville
marked this pull request as ready for review
October 27, 2026 17:11
While profiling Go collection listing, I found that restoring the cache copies a result list for every key referring to it. An earlier cache had 2,606 keys pointing to 2,605 module results, which created 6.8 million index entries for that group alone. Keep one shared list for each imported group and track its members for cleanup. Later additions stay local to their key. Merging groups and removing results preserve what each key can find. Access uses the existing lock and the disk format stays the same. On main 3eb7f1e, the 2,049-result fixture allocated 227.81 MB before and 25.90 MB after. The control with 2,048 separate lists added about 64 kB. Those are earlier allocation measurements; a current full-listing speedup has not been established. The full DagQL race suite passes on the beta21-main rebase. Tests cover additions, merges, overlapping imported groups and cleanup that retains later additions. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
pr/go-collections-restored-index
branch
from
October 27, 2026 17:53
9253cb9 to
59d21e8
Compare
Signed-off-by: Guillaume de Rouville <[email protected]>
sipsma
approved these changes
Oct 27, 2026
sipsma
left a comment
Contributor
There was a problem hiding this comment.
LGTM. Just make sure lint is green before merging.
tiborvass
approved these changes
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.
While profiling Go collection listing on dagger/dagger, I found that restoring the cache builds a separate result-index tree for every key, even when many keys point to the same results.
An earlier snapshot from the listing experiments had 2,606 keys pointing to 2,605
GomodGoModresults. Restoring that group alone created 6.8 million index entries. The cache accumulated during these experiments; it is not a claim about a typical user's cache.Share each imported result list between its keys instead. Track which shared lists contain a result so cleanup can remove it from each list once. Later additions stay local to their key, and merging groups preserves what existing keys can find. All access uses the existing cache lock; the disk format stays the same.
Memory on the retained engine cache
I checked this change alone on engine main 14c1942e, using the same retained cache volume. Each snapshot follows a successful small Go collection listing and session cleanup, with no active clients. Telemetry and ordinary GC remain enabled; there is no cache reset or forced GC.
HeapAlloc)These are individual memory snapshots in decimal GB, not peak memory or command timings. Switching back to main brings the larger footprint back. Unforced heap profiles attribute several GB to the result-index trees allocated by
importPersistedState; that allocation largely disappears with this change. Profile samples can lag GC, so I am not treating their exact byte counts as current heap usage.The cache contains heavily shared result lists. Smaller caches, or caches whose keys have separate results, will save less. The extra membership tracking also has a cost when there is little to share.
Allocation controls
Earlier component checks on main
3eb7f1eaused identical benchmark code and cache fixtures on both versions:These measure total allocation for each operation, in decimal MB, from two alternating pairs. The separate-list control costs about 64 kB more. Fresh insertion and cleanup allocations are effectively unchanged in this sample. The host was busy during those checks, so their elapsed times are not latency evidence.
Validation and remaining work
The patch is now rebased onto main
930485687df5c9a7ed521f5585a17b2a36936b17(beta21), where the full DagQL race suite passes. The tests cover additions to individual keys, group merges, removal from overlapping imported groups, and retaining later additions when an imported group becomes empty. The measurements above remain tied to their recorded earlier commits.go test -race -count=1 ./dagqlThis remains draft. The memory reduction is established for the retained cache shown above, which has many keys sharing result lists. A complete warm Go listing speedup from this change alone on the current Go module is not established.