Repository navigation
Conversation
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
This was referenced Oct 29, 2026
Contributor
|
This continues in #250, rebased onto current main with fixes from review. Guillaume's two commits are there unchanged, with him as author. |
sipsma
added a commit
to grouville/dagger
that referenced
this pull request
Nov 3, 2026
The engine pinned Guillaume's fork of Dang for vito/dang#211, which adds PrepareDir and PreparedDirectory.Evaluate. vito/dang#250 carried that change onto Dang main and merged, so Dang now moves to its merge commit and the replace of the fork goes away. Since the merge of vito/dang#213 that Dang was on before, Dang's type checker became stricter (vito/dang#230 to #235, #246 and #249): programs it accepted that could fail at runtime are now type errors, so a module that loaded before may now fail to load. Among them, operators need non-null operands, Map.get is typed as nullable (vito/dang#215), and a decode result must be given a type before it is used. Function parameters match by name, so a positional call through an interface binds in the interface's order. YAML << merge keys are resolved when decoding (vito/dang#217), and malformed syntax is reported instead of panicking the parser (vito/dang#243). The release note describes what module authors will see. Signed-off-by: Erik Sipsma <[email protected]>
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.
The native Dang SDK evaluates the same module source for many function calls. Each call currently creates a fresh inferred program, even when the source and imported GraphQL schema are unchanged. Small collection getters make that repeated compiler work visible.
I added
PrepareDirandPreparedDirectory.Evaluateso an embedder can finish parsing and whole-directory type checking once, then evaluate that program with fresh runtime state for each call. ExistingRunDircallers keep their current behavior.Preparation completes interface linking and effect checking before the program can be shared. Every evaluation still creates fresh values, closures, import bindings and services, and reruns module initializers. GraphQL clients come from the current call. A changed import schema is rejected. The prepared program retains no client or caller context.
Scalar hooks, static namespaces and native Dang imports still keep runtime state in their type graphs.
PrepareDirreturnsErrUnpreparableDirectoryfor those declarations, allowing the embedder to useRunDirbefore executing any user code. An evaluation failure must be returned without retrying throughRunDir, because that could repeat effects.The motivating measurement is Dagger's full Go test listing:
dagger check --module go --check test --list --allWith only prepared compilation enabled in the engine, the median fell from 25.793s to 19.926s: 5.87 seconds saved, 23% lower latency. Engine CPU fell from 119.505s to 76.350s (36%). The CLI, Go module source and public API were unchanged.
This measures this API together with the Dagger engine adapter, dagger/dagger#14953. Adding an unused API to Dang alone does not speed up existing callers. It does not include the separate Go discovery index, bulk listing or telemetry batching changes. Controls drifted, so the headline uses the conservative before comparison rather than the larger pooled result.
The benchmark uses collection engine #14802 at
97a8621c57privately combined with main5c4cdd243b, Dangaaa6cfeacd, and dagger/go#84 ateecde50722. This patch is ported onto Dang main10fb92d. Measurements use a warmed 8-CPU engine and a fresh CLI after an ordinary source edit plus a unique added test on every invocation. All 4,706 expected tests, order, full normalized stdout, the added test and successful exit through normal cleanup are verified. Preparation runs are retained separately. wcprof and CPU/allocation profiles were captured.Validation covers current clients under concurrent evaluation, initializer execution, copy-on-write behavior, interfaces, closures, private members across files, error locations, changed schemas/source, retries and unsupported declarations. The corpus check runs ordinary evaluation and three concurrent prepared evaluations for each of 229 eligible pure language programs; imported integration fixtures and unsupported runtime type declarations have separate tests. Actual Dagger check execution and the Go catalogue/manual-operation regression also passed on the benchmark version.
On current Dang main, the full
go test ./pkg/dang -count=1suite passes (12.658s), andgo test -race ./pkg/dang -run '^TestPreparedDirectory' -count=1passes (28.819s), including those 229 programs. The Dagger adapter's current-main concurrency/session-release race test also passes.The full Dang race suite fails the existing
TestFormat/TestNestedOneLineBlocksFormatQuicklyfive-second timing limit. The same focused formatter race test also fails on unchanged main10fb92d(30.165s total). I have kept that failure visible and left the formatter and its test unchanged. This draft needs review of the API/fallback boundary before the engine can pin an upstream version.An independent repeat using the same frozen engine and published Go module refs reproduced the compiler benefit: candidate 20.124 / 19.443 / 20.317s; controls 26.570 / 28.518s before and 26.018 / 25.426s after. Median latency is 20.124s versus 25.722s for the faster control block (22% lower), or 26.294s pooling controls (23% lower). Engine CPU is 75.20s versus 120.52s. Every expected output check passed. A separate comparison on today's main plus the current collection prerequisites is in progress; this repeat is not claimed as that current-main result.
Current-code combined check (2026-10-29): main
4342720d00plus collection branch636dd96749, with Go #84 at1572fd4634, measured 15.505s median after adding the open bulk-listing, prepared-compilation and Go-index changes. Runs were 15.505 / 15.255 / 15.679s. Baseline runs were 28.339 / 26.209s before and 24.745 / 26.245s after. Using the faster control block gives 25.495s → 15.505s, 39% lower latency; pooled controls give 41%. Engine CPU is 116.32s → 35.73s.That is the combined stack, not this PR's standalone contribution. Engine/CLI code is current; the workload is the same fixed 4,706-test root-Go fixture in all arms, with a fresh source edit and unique added test each time. Complete ordered stdout and normal cleanup pass. All arms also contain the identical small table-output buffering fix, prepared separately after the unmodified current CLI silently dropped stdout fragments. That shared prerequisite is not attributed to these performance changes. Telemetry batching and discovery-only scanning are absent from this combined result.