Repository navigation
perf(dang): reuse decoded API schemas for native calls - #14808
Merged
tiborvass merged 1 commit intoOct 27, 2026
Merged
Conversation
grouville
force-pushed
the
perf/native-dang-schema-decoding
branch
2 times, most recently
from
October 23, 2026 08:42
8994a8f to
cb5c900
Compare
grouville
marked this pull request as ready for review
October 27, 2026 17:09
Every native Dang call decodes its API schema before running the module. Go test discovery repeats this for each package, even when the calls use the same immutable schema file. Reuse the decoded metadata through the existing DagQL cache, keyed by the schema file ID. Keep a separate schema wrapper and type slice for each call, since module initialization can append its own type placeholders. Clients, type inference and evaluation remain local to each invocation. The cached metadata is released after the last session using it ends. Cover concurrent calls with different clients, module-local type changes, different schema files, failed reads and session cleanup. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
force-pushed
the
perf/native-dang-schema-decoding
branch
from
October 27, 2026 17:52
cb5c900 to
97bd0d7
Compare
sipsma
approved these changes
Oct 27, 2026
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.
Listing Go tests makes many native Dang calls while discovering packages and their tests. Each call opens and decodes its API schema, even when other calls have already decoded the same immutable file. In the latest full-listing profile, decoding schemas accounted for about 32 CPU-seconds across 1,602 native calls. That is CPU time summed across concurrent calls, not 32 seconds of command time.
Reuse the decoded schema through the existing DagQL cache, keyed by the schema file ID. Each call keeps its own schema wrapper and list of types, so adding module-local types cannot affect another call. Clients, type inference and execution remain separate. No new lock or LRU is added.
This is part of the work to make Go collection listing faster.
dagger check --module go --check test --list --allThe full listing saves about 4.3 seconds, or 5.6%. Engine CPU time falls from 366.86 to 331.54 CPU-seconds. These are medians from two warm measurements per version in A–B–B–A order; the small control has eight measurements per version. Every command starts a fresh CLI after source and test edits, returns all expected rows in order, and completes cleanup. Telemetry and normal GC remain enabled. Each engine completes a preparation command before timing.
The cost is holding decoded schema metadata while a session uses it, plus copying the outer wrapper and type list for each call. The existing cache releases that metadata after the last session using it ends. Sampled engine-container memory was 16.34 → 15.85 GB for the large case and 2.21 → 2.25 GB for the small control; these samples do not establish a peak-memory improvement.
Measurement setup
The full selection is the root Go module in dagger/dagger at
ff0b029a, withtest = ["."], not every nested module. There are 4,398 existing rows plus the test added for each measurement.Both timed versions use engine 14c1942, with #14730, #14738, #14806, the merged Dang parser improvement and Dang #205 held constant. The full case uses Go main at
bf45651plus Go #68; the small control uses that Go main without #68. Both use the same development CLI, including a common stdout-buffer correctness fix, and the same retained cache with eight CPUs and a 40-GiB limit. Profiling is off during measurements; no cache reset or forced GC is used.Only decoded-schema reuse differs. These numbers measure its contribution on that stack, not a comparison with stock main. The PR itself is a standalone change on current upstream main.
The tests cover concurrent calls using different clients, isolation of module-local types, separate schema files, retry after a failed read, and release after the last session ends. They also check that evaluating imports leaves the shared schema metadata unchanged. The SDK race suites pass on the benchmark stack and on the standalone upstream-main branch.
go test -race -p=2 -buildvcs=false ./core/sdk/dang/v2 ./core/sdk/dang/shared