GeezerVison is showing github.com — engine: prune DAGQL cache by metadata size by sipsma · Pull Request #13846 · dagger/dagger
Conversation
sipsma
commented
Aug 5, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
Summary
Persisted DAGQL cache roots can retain substantial in-memory result, e-graph, module, and schema state while consuming little or no physical cache space. Existing automatic pruning is triggered by disk usage, so those roots can remain indefinitely when disk thresholds are not crossed.
This change adds a coarse structural estimate for DAGQL cache metadata:
3072 * results + 512 * terms + 768 * allocated equivalence-class slots
Reading the estimate is O(1) and allocation-free because these counts already exist in the cache. When the estimate exceeds the provisional 4 GiB maximum, the engine uses the existing pruning candidate order and ownership simulation to prune toward 3 GiB. This makes zero- and tiny-disk persisted roots eligible without weakening active-session or unpruneable-root protection.
Disk GC remains independent. Disk-stat failures do not suppress structural pruning, and structural no-progress suppression does not suppress disk policies. The persistence schema remains version 17; an oversized graph may still create an import peak before the scheduled startup trim.
The change also adds:
gc.dagqlCache.maxEstimatedBytes and targetEstimatedBytes configuration;
dagger_dagql_cache_metadata_estimated_bytes;
- aggregate-only pruning logs and traces;
- schema-17 restart/startup coverage, zero-disk integration coverage, race tests, and scale/calibration benchmarks.
The 4 GiB/3 GiB defaults are provisional rollout values. The estimate deliberately approximates cache-owned memory rather than attributing exact retained heap.
Performance
At one million results on the benchmark host:
- estimate read: 6.5 ns/op, zero allocations;
- structural snapshot: 1.004 s, versus 2.025 s for the existing disk snapshot path;
- slowest measured full-prune fixture: 27.318 s;
- maximum sampled pruning scratch: 888,102,912 bytes;
- sparse forced class compaction from 1,000,000 slots to 2,000: 31.7 ms write-lock hold.
Testing
On the rebased head:
go test -race ./dagql -run '^(TestCacheMetadata|TestCachePruneMetadata|TestRemovePersistedEdge|TestLazyRefArg)' -count=1
go test -race ./engine/server -run '^(TestResolveDagqlCacheGCConfig|TestGCLocked.*Metadata.*|TestScheduledGCTrimsImportedMetadataWithoutPersistenceReset|TestLocalCachePressureCheckUsesMetadataWhenDiskStatFails|TestMetadataPrune.*|TestMonitorMetadata.*|TestGCSessionCompletionClearsMetadataPruneBlock|TestExplicitPruneClearsMetadataPruneBlock|TestCanceledMonitorMetadataPruneDoesNotSetBlock|TestEnsureWorkspaceLoaded.*)$' -count=1
go test ./dagql ./engine/server ./engine/engineutil ./core/schema -count=1
go test ./cmd/json-schema ./engine/config -count=1
go run ./cmd/json-schema engine.json > /tmp/engine.schema.json
cmp docs/static/reference/engine.schema.json /tmp/engine.schema.json
dagger api call engine-dev test --pkg ./core/integration --run='TestLocalCache/TestDagqlMetadataGCProtectsActiveZeroDiskResults'
dagger api call engine-dev test --pkg ./core/integration --run='TestEngine/TestPrometheusMetrics'
The metadata-pressure E2E passed with trace b22591406cd051b4de63502a8d7ae884; the metrics E2E passed with trace 9146773cba455b106d9255c81edf24e8.
After the lint-only follow-up commit, the affected server race suite and repository lint check also passed:
go test -race ./engine/server -run '^(TestResolveDagqlCacheGCConfig|TestGCLocked.*Metadata.*|TestScheduledGCTrimsImportedMetadataWithoutPersistenceReset|TestLocalCachePressureCheckUsesMetadataWhenDiskStatFails|TestMetadataPrune.*|TestMonitorMetadata.*|TestGCSessionCompletionClearsMetadataPruneBlock|TestExplicitPruneClearsMetadataPruneBlock|TestCanceledMonitorMetadataPruneDoesNotSetBlock)$' -count=1
dagger check 'golang:lint-all'
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Lower the class-slot coefficient to 768 bytes after the required 200k churn benchmark measured the 1024-byte hypothesis at a 2.199 estimate-to-post-GC-heap ratio. The calibrated coefficient measures 1.649 while preserving the approved structural formula and keeping a common one-million-entry graph above the 4 GiB trigger.
Signed-off-by: Erik Sipsma <[email protected]>
grouville
left a comment
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While testing this branch I think I might have found a small race in pruning. It may be a known trade-off, so genuine question at the end, AND, as it's best effort, approving to unblock. LGTMm after the linting issues get fixed ✅
The scenario:
- Pruning starts by taking a snapshot of the results that active sessions are using, and builds its plan from that.
- Right after that, a new session gets a cache hit on a persisted result.
- Pruning applies the plan and deletes that result's persisted edge. Before deleting, it re-checks the
unpruneable flag, but not whether a session started using the result in the meantime.
Nothing crashes: the session keeps its reference and finishes fine. But when the session closes, the result is dropped from the cache, so the next run has to rebuild it. This matters more with this PR, because metadata pruning now runs in the background whenever the estimate goes over the limit: exactly when sessions are live and getting hits.
I've tried checking the docs you made on the subject, it seems to read both ways: "ownership may have changed... The implementation accepts that", but also "prune will not cut it while it is still in that active closure".
I guess it's an accepted trade-off, just questioning wether it's worth closing?
In case it's the latter, I've made a small repro and a possible fix: grouville/dagger@repro-dagql-prune-active-session-race
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
While testing this branch I think I might have found a small race in pruning. It may be a known trade-off, so genuine question at the end, AND, as it's best effort, approving to unblock, after the linting issue gets fixed ✅
The scenario:
1. Pruning starts by taking a snapshot of the results that active sessions are using, and builds its plan from that.
2. Right after that, a new session gets a cache hit on a persisted result.
3. Pruning applies the plan and deletes that result's persisted edge. Before deleting, it re-checks the `unpruneable` flag, but not whether a session started using the result in the meantime.
Nothing crashes: the session keeps its reference and finishes fine. But when the session closes, the result is dropped from the cache, so the next run has to rebuild it. This matters more with this PR, because metadata pruning now runs in the background whenever the estimate goes over the limit: exactly when sessions are live and getting hits.
I've tried checking the docs you made on the subject, it seems to read both ways: "ownership may have changed... The implementation accepts that", but also "prune will not cut it while it is still in that active closure".
I guess it's an accepted trade-off, just questioning wether it's worth closing?
In case it's the latter, I've made a small repro and a possible fix: grouville/dagger@repro-dagql-prune-active-session-race
That scenario was present before the changes here and while it's a legit possibility it is indeed something we just accept as a tradeoff. The problem is that rechecking adds quite a bit of overhead (i.e. the fix you linked to has to re-scan a potentially large map while holding an contended lock and repeats that work for each edge being considered for removal). We don't want pruning to be a "stop-the-world" type GC and accept that what gets pruned and what gets retained is intrinsically timing and heuristic based anyways, which is okay since it's managing a cache (as opposed to a database or something).
|
grouville reacted with heart emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
social4hyq
pushed a commit
to social4hyq/homebrew-core
that referenced
this pull request
Sep 20, 2026
dagger 0.21.9
Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`
---
Created with `brew bump-formula-pr`.<details>
<summary>release notes</summary>
<pre>## v0.21.9 - 2026-08-25
### Added
- Added SSHFS-backed volumes, allowing remote filesystems to be mounted into containers without copying their contents into Dagger's content store by @sipsma in dagger/dagger#13462
### Fixed
- `Container.withDirectory` and `Directory.withDirectory` no longer restore by @sipsma in dagger/dagger#13848 \
deleted nested files after execs remove and recreate an ancestor
directory.
- Engine client enumeration no longer blocks behind another session's by @sipsma in dagger/dagger#13542 \
initialization or teardown, preventing Cloud keeper heartbeats from stalling
and live engines from being suspended.
- Session teardown now runs in the background after the main client disconnects, by @sipsma in dagger/dagger#13681 \
preventing shutdown responses from timing out while the engine releases
session-owned cache results.
- The engine now bounds retained DAGQL cache metadata independently of disk by @sipsma in dagger/dagger#13846 \
usage by pruning cold persisted results when the structural estimate exceeds
its configured limit. This may mitigate metadata growth at scale while
preserving active and engine-lifetime cache roots.
- Registry protocol probes no longer appear as scary errors in progress output by @vito in dagger/dagger#13410 \
when image pulls or publishes succeed, while genuine registry failures remain
visible.
- Registry authentication no longer invalidates downstream container cache reuse across sessions when applied before or after `Container.from` by @sipsma in dagger/dagger#13901
### What to do next?
- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)
</pre>
<p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.9">https://github.com/dagger/dagger/releases/tag/v0.21.9</a>.</p>
</details>
<hr>
See merge request: Harmonybrew/homebrew-core!17786
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
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.
|