Skip to content

[backport-0.21] engine: prune DAGQL cache by metadata size - #13886

Merged
sipsma merged 22 commits into
dagger:backport-0.21from
sipsma:backport-13846-0.21
Aug 13, 2026
Merged

sipsma merged 22 commits into
dagger:backport-0.21from
sipsma:backport-13846-0.21

Conversation

@sipsma

@sipsma sipsma commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Backports the complete metadata-aware DagQL cache-pruning behavior from #13846 to v0.21:

  • tracks a coarse structural metadata estimate (3072*results + 512*terms + 768*class slots)
  • prunes cold persisted roots toward a metadata target independently of disk usage
  • protects active-session and engine-lifetime/unpruneable closures
  • schedules structural checks for startup, session completion, graceful shutdown, explicit GC, and the pressure monitor
  • handles zero-disk metadata pressure, estimator correction, forced sparse-class compaction, and monitor no-progress blocking
  • adds gc.dagqlCache.maxEstimatedBytes / targetEstimatedBytes, the dagger_dagql_cache_metadata_estimated_bytes metric, bounded aggregate observability, tests, scale benchmarks, docs, and a v0.21.9 change entry

This bounds retained metadata growth and may mitigate scale-related symptoms. It does not claim to directly fix the reported egraphMu / startup contention.

The separate bounded manual structural-prune API discussed with Erik is intentionally not included because it was not part of #13846. The source defaults remain unchanged at 4 GiB maximum / 3 GiB target.

Source PR and commits

  • Source: engine: prune DAGQL cache by metadata size #13846
  • Exact source series: 615a02dbdaf6ef107f8a1dfa3c45d39624403645^..b19467f2b032bb4c000c5c80bbe21ac062ac03f5 (20 commits; parent ba839a98077aef4398415ccc805f57fd694c2e4b)
  • Metadata-pruning backport series: f021d54d4c0824061690fa4669fc39d39183d4d1^..0371e77ae8210df2f7583e2fa0ac39b08019f32f, followed by v0.21 adaptation commit 5479f384e8bff0e2d87d981838528adbe755ef2c
  • CI fixture source: fix(ci): use project deploy tokens for GitLab #13849; source PR commit 0c656b9ca6395fdec1f051d34987bb4f8864196a; merged main commit 66337ba5d3d01ae10a0d7fb97ebe4dec9326e8bc
  • Proven v0.21 fixture backport: becaa3a33542ccc7e96dbf3f430d887f41958e52, validated on [backport-0.21] fix: hide registry HTTP probe errors #13885 and initially cherry-picked unchanged as f951484dde70cd431a5e19f84027aa4eaa946367; after two byte-identical CI head refreshes, the current equivalent tip is 89af13099acc7a46885023b096b25372e32931f4 (tree 631aa606fb061a4464f838559c2569c25bb9eb9b)

All 20 metadata-pruning source commits, including the design-review history, are preserved in order with cherry-pick -x; none were squashed or omitted. The additional v0.21 adaptation and fixture-propagation commits are also DCO-signed. The fixture commit preserves Guillaume de Rouville as author and the source traceability footer.

Prerequisite

#13375's GC pressure-monitor machinery is already present on backport-0.21 as 78fc50e58a4f417825e414463829c1bc7c2053d2. Its stable patch ID matches source commit 838b7c73ab69fb5bc97cfa1139478ae7d305e4ed, so this backport relies on the existing v0.21 implementation rather than duplicating it.

v0.21 adaptations

  • Preserved v0.21's existing stateMu graceful-stop/session lifecycle and namespace-worker initialization while applying the new scheduler/config state. Main-only core.SetWorkspaceInvalidator, recursive-read-only-mount context, and a session-test field rename are absent from v0.21 and were not pulled in as unrelated changes.
  • Kept the cache-pruning reference in its v0.21 location under skills/cache-expert/references/.
  • Adapted restart documentation and the large persistence benchmark from main's schema 17 to v0.21's unchanged schema 16; no persistence schema bump or worker reset was introduced.
  • Adapted the active zero-disk integration workload from main's dagger api with-session spelling to the equivalent v0.21 dagger run command.
  • Added the v0.21.9 unreleased change entry with source attribution Author: sipsma, PR: 13846.
  • Added exactly the proven six-file v0.21 GitLab fixture backport from [backport-0.21] fix: hide registry HTTP probe errors #13885 with no further adaptation. It replaces revoked user PAT usage with read-only project deploy tokens and propagates each required username through the existing integration-test authentication paths; no product code or diagnostics changed.

Validation run

  • ./dagql: 295 tests passed — pruning semantics, trigger/target correction, active/unpruneable protection, no-detail structural mode, compaction, persistence/restart, and estimator accounting. trace
  • ./engine/server: 61 tests passed — defaults/config resolution, no-disk-stat behavior, lifecycle scheduling, pressure monitoring, blocked/no-progress recovery, explicit/session reset behavior. trace
  • ./engine/config: compiled successfully (no package tests). trace
  • ./cmd/engine: 7 tests passed. trace
  • TestEngine/TestPrometheusMetrics: 2 tests passed and observed the new metadata gauge. trace
  • TestLocalCache/TestDagqlMetadataGCProtectsActiveZeroDiskResults: 2 tests passed; the workload remained active through a pressure-monitor interval, produced metadata growth with only 4 KiB disk use, stayed protected while active, then closed and was structurally pruned. trace
  • All seven one-shot metadata benchmarks passed at their defined 200k/1M scales: allocation-free estimate, metadata-vs-disk snapshots, full prune, four fixture calibrations, correction/churn, sparse forced compaction, and schema-16 import. The 1M import retained schema 16 and peaked at 4,526,727,168 B additional HeapInuse; 1M metadata pruning removed all roots in ~14.7 s with ~893.8 MB peak scratch. trace
  • Root Go check-tidy passed. trace
  • Historical CI on 5479f384e8bff0e2d87d981838528adbe755ef2c passed DCO and 69 Dagger Cloud contexts; five split suites failed only where GitLab rejected the revoked private-fixture PAT. base trace, call/shell trace, CLI/engine trace, container trace, modules trace.
  • Canary [backport-0.21] fix: hide registry HTTP probe errors #13885 proved becaa3a33542ccc7e96dbf3f430d887f41958e52: all 75 applicable checks passed, including all five formerly failing shards and TestPrivateGitRepoArgCaching in real CI.
  • The propagated patch is byte-for-byte equivalent by stable patch ID (c5ece8f8d50919d36bdb6abad1e312d65ae8a2bf), changed only the same six integration-test files (35 additions, 30 deletions), and passed git diff --check. Final head 89af13099acc7a46885023b096b25372e32931f4 passed all 75 applicable statuses (74 Dagger Cloud contexts plus DCO). Initial failures were trace-classified rather than dismissed: Linux/arm64 Wolfi release exited 139 (failed trace, final pass); telemetry saw a runtime-only 13.6% dropped golden suffix (failed trace, final pass); and one 441/442 module-runtime run failed during pinned Python 3.13.1 initialization (failed trace, final pass). dagger cloud rerun could not resolve the cross-fork PR or synthetic merge SHA from this runner, so the two retries used committer-timestamp-only tip refreshes, byte-identical tree checks, and explicit --force-with-lease.
  • During final stewardship, backport-0.21 advanced from 9f68624bf69c23c01861e298651656ecac780285 to 269c47d7708b4623c3fbfdcd2440d19a055dc7e0 via [backport-0.21] fix: hide registry HTTP probe errors #13885, which independently absorbed the same six-file fixture patch (stable patch ID c5ece8f8d50919d36bdb6abad1e312d65ae8a2bf) alongside its registry-observability fix. Final green synthetic merge 86bdee550d36867afd02cfdd8d44b08ccebaae79 has exact parents base 269c47d7708b4623c3fbfdcd2440d19a055dc7e0 and head 89af13099acc7a46885023b096b25372e32931f4; the retained traceable head commit merges without conflict or behavioral duplication. Upstream squash commit 49559d42c9c9dc2588dc53f834e15ea572f69ae7 has the identical tree 3821ccc63bdbed5ee821980aa6893b9eea7044be.
  • GitHub's check-for-changelog job was intentionally skipped because the PR has no needs/changelog label; the release entry is present and Dagger Cloud's changelog:generate check passed.
  • Changed Go files are gofmt-clean; git diff --check passed; all 22 commits have DCO signoff; gc: prune local cache during disk pressure #13375 prerequisite patch IDs and all 20 -x source footers were audited.

Release note

Adds .changes/unreleased/Fixed-20260812-213129.yaml for v0.21.9, attributed to source PR #13846. The GitLab fixture propagation is test-only and adds no separate release entry.

Risk and remaining work

This was published and fully validated as a draft because it is a large engine/cache backport. GitHub records sipsma as squash-merging it at 2026-08-13T02:58:09Z, after the final green run. The revoked GitLab fixture credential was addressed by propagating the exact six-file v0.21 patch proven on #13885, and the final combined-head matrix has converged green. The complete integration suite beyond the published split coverage remains unrun.

The root full-lint command was attempted but is currently blocked by unrelated generated docs snippets (default-address/go) that cannot import their generated internal package. Targeted go vet was also attempted; it reports pre-existing context-cancel findings in dagql/cache.go (blamed to aa719a10d52, before this series) and engine/server/session_attachables.go (74c2889afc6, untouched here). Those unrelated findings were not changed to keep this backport scoped.

The estimator is deliberately coarse and structural rather than RSS-based. A pre-existing oversized schema-16 graph is fully imported before the one-second startup prune, so a temporary upgrade/startup memory peak remains possible. This patch bounds retained metadata after pruning; it does not establish a direct fix for lock contention.

sipsma added 21 commits August 12, 2026 21:27
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 615a02d)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit b087da9)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit fa45dbd)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 0a46329)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit d114c9a)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit d801635)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 27fc2b5)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit dc1e998)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 348fbe2)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 4573145)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 73687bb)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 49c3302)
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]>
(cherry picked from commit c81de1c)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit ca83937)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit d032d00)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 686e238)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 938cc52)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 3b5780b)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 06c452b)
Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit b19467f)
@sipsma sipsma added this to the v0.21.9 milestone Aug 12, 2026
@grouville
grouville self-requested a review August 12, 2026 22:46
@sipsma
sipsma force-pushed the backport-13846-0.21 branch from f951484 to e6b8f7c Compare August 13, 2026 02:19
GitLab automatically revokes user PATs when it detects that they were leaked.
That is what these private repository tests used, and both tokens were
revoked. GitLab does not document the same automatic response for project
deploy tokens.

Replace the PATs with read-only deploy tokens scoped to the test project.
Deploy tokens use a username and token pair, so pass the matching username
through each Git authentication path.

These credentials are intentionally committed for end-to-end tests. They can
only read one disposable test repository, which contains no private code or
data, so exposing them does not grant access beyond the test fixture.

Keep both credentials in the shared VCS fixture so future rotations happen in
one place. The second token is still needed to test two different credentials
for the same repository.

Signed-off-by: Guillaume de Rouville <[email protected]>
(cherry picked from commit 66337ba)
Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the backport-13846-0.21 branch from e6b8f7c to 89af130 Compare August 13, 2026 02:38
@sipsma
sipsma marked this pull request as ready for review August 13, 2026 02:57
@sipsma
sipsma requested a review from a team as a code owner August 13, 2026 02:57
@sipsma
sipsma merged commit 49559d4 into dagger:backport-0.21 Aug 13, 2026
76 checks passed
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