Skip to content

core: read cache-evidence frame facts without cloning the frame - #14627

Merged
sipsma merged 2 commits into
dagger:mainfrom
sipsma:g22-evidence
Oct 14, 2026
Merged

sipsma merged 2 commits into
dagger:mainfrom
sipsma:g22-evidence

Conversation

@sipsma

@sipsma sipsma commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

At the end of every recorded call span, core.recordCacheEvidence stamps the output's content digest and type name. It read both through res.ResultCall(), which deep-clones the call's whole recipe DAG. On a long receiver chain, such as a container built up step by step, that clone dominated the function.

This change adds dagql.ResultFrameFacts, which reads the two facts from the result's stored call frame directly. The recorded evidence is unchanged:

  • the stored frame's published type and extra digests aren't mutated in place; content is learned on a fork that's then published;
  • ResultCall is implemented only by Result[T] (and ObjectResult[T], which embeds it), so the facts come from the same frame as before;
  • results without a frame still record neither fact.

Measurements

  • Microbenchmark (BenchmarkRecordCacheEvidence, a 32-step receiver chain with content): 17.6 µs → 0.32 µs per span, 21.9 KB → 1 KB and 207 → 5 allocations.

  • End to end, on per-package Go builds (yq v4.49.2, one exec per package, 262 packages, concurrency 16, 12-CPU VM): an ABBA series (4 fresh engines per arm) measured this together with a second, independent telemetry fix (span attributes no longer JSON-encoded twice; separate PR). Medians of wall time, main → both fixes:

    • edit of one yqlib string (3 packages rebuild): 2185 → 1940 ms; ranges overlap (1930–2260 vs 1920–2000);
    • first build: 11830 → 11715 ms, within noise;
    • no change: 935 → 895 ms, within noise.

    The edit result is suggestive rather than established. Nothing regressed, and every run rebuilt exactly the expected packages.

Tests

  • TestResultFrameFacts checks that the facts match cloning the frame with ResultCall, with and without a content digest, and the nil case.
  • The existing cache-evidence tests still pin both attributes on detached and cache-backed results.
  • These run in the package tests (test-split/test-packages). BenchmarkRecordCacheEvidence covers the cost.

In CI (on this PR's head commit, rebased onto main): TestResultFrameFacts and the existing cache-evidence tests ran and passed in the test-split/test-packages check (trace): dagger trace 101ff9d4d5d564984f07c50f526ea6a6 --test TestResultFrameFacts. All checks are green.

sipsma added a commit to sipsma/dagger that referenced this pull request Oct 10, 2026
sipsma added a commit to sipsma/dagger that referenced this pull request Oct 13, 2026
sipsma added a commit to sipsma/dagger that referenced this pull request Oct 14, 2026
sipsma added a commit to sipsma/dagger that referenced this pull request Oct 14, 2026
recordCacheEvidence runs at the end of every recorded call span and read the
output content digest and type name through ResultCall, which clones the
frame's whole recipe DAG. On a long receiver chain that clone dominated the
function: 207 allocations per call for a 32-step chain.

Read both facts from the shared frame, which is immutable once stored, via a
new dagql.ResultFrameFacts. The recorded evidence is unchanged.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma merged commit 1171632 into dagger:main Oct 14, 2026
94 checks passed
sipsma added a commit to sipsma/dagger that referenced this pull request Oct 20, 2026
…en its producer's session is removed

Add a test for a failure first seen when a superseded check was cancelled:
a php-client/test run of dagger#14627 failed with "acquire shared client scope:
session ... is closed", naming the session of dagger#14626's php-client/php-stan
check on the same engine (traces 51ab194ff7d2c48ac494ff453b55daf7 and
68db9b2801268c97c90d34fcc9d617f5).

dagger#14047 gave client work typed lifecycle leases: a call shared across
sessions runs under a lease cloned from the session that started it, and
a session marked removed refuses every further clone, even from a lease
it still holds. Session removal marks the session removed before it
waits for its leases to drain, so shared work can still be running when
its producer's session is marked removed. A nested call that work then makes fails
to clone the producer's scope, and the call's other waiters receive that
error although their own sessions are alive.

The test builds two sessions with the client lifecycle tests' harness, a
real dagql cache, and a call both share. It waits for the second session
to join the call, marks the producer's session removed as session
removal begins, then lets the shared work make its nested call, and
asserts the desired behaviour: the surviving waiter gets the call's
value, whether from the shared work or by taking it over. It fails today
with the producer's closure, every run. It covers the early teardown
window, before the cache releases the producer's session.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit to sipsma/dagger that referenced this pull request Oct 21, 2026
…en its producer's session is removed

Add a test for a failure first seen when a superseded check was cancelled:
a php-client/test run of dagger#14627 failed with "acquire shared client scope:
session ... is closed", naming the session of dagger#14626's php-client/php-stan
check on the same engine (traces 51ab194ff7d2c48ac494ff453b55daf7 and
68db9b2801268c97c90d34fcc9d617f5).

dagger#14047 gave client work typed lifecycle leases: a call shared across
sessions runs under a lease cloned from the session that started it, and
a session marked removed refuses every further clone, even from a lease
it still holds. Session removal marks the session removed before it
waits for its leases to drain, so shared work can still be running when
its producer's session is marked removed. A nested call that work then makes fails
to clone the producer's scope, and the call's other waiters receive that
error although their own sessions are alive.

The test builds two sessions with the client lifecycle tests' harness, a
real dagql cache, and a call both share. It waits for the second session
to join the call, marks the producer's session removed as session
removal begins, then lets the shared work make its nested call, and
asserts the desired behaviour: the surviving waiter gets the call's
value, whether from the shared work or by taking it over. It fails today
with the producer's closure, every run. It covers the early teardown
window, before the cache releases the producer's session.

Signed-off-by: Erik Sipsma <[email protected]>
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