Repository navigation
Workspace overlay & export - #13600
Conversation
8880972 to
5251804
Compare
| if ws.HostPath() == "" { | ||
| return rootfs, fmt.Errorf("workspace has no root filesystem") | ||
| } | ||
| return s.resolveRootfs(ctx, ws, ".", core.CopyFilter{}, false) |
There was a problem hiding this comment.
Rebased my LLM work on top of this and noticed this ends up doing a full upload:
▶ ✔ current-workspace | with-new-file hello.txt hello | changes 21.7s
Changeset@xxh3:dcc3b5fbba6b2752
✔ uploading /home/vito/src/dagger/llm-workspace 21.7s ████████████ 90 MB
It would be nice if that could be skipped somehow, since the end goal is producing a Changeset anyway which are meant to just represent the delta in scenarios like this.
There was a problem hiding this comment.
I agree but I think that would require more work than this PR supports. I added a comment to track this. Do you agree with it?
There was a problem hiding this comment.
The full sync is pretty painful when an agent makes minimal changes so I think we'll feel this pretty quickly, but it's still better than erroring so I'm happy to keep iterating on it in future PRs, don't wanna block this one.
Here's what my LLM came up with, for what it's worth: vito@8e2ffa5 - haven't fully tested yet
NOTE: GitHub only shows one file in its UI for me; seems like a bug. Here's a gist version
Basically it builds up changes on an empty base and tracks which files actually changed, and then syncs only those paths, since we still need to do that for an accurate diff. (e.g. if something fully rewrote README.md we still want to see the diff compared to the previous version even if it used withNewFile to clobber it).
There was a problem hiding this comment.
From what I can tell, this full sync applies to dagger install, dagger workspace config, etc. So it's going to be a pretty painful regression in common paths. Seems worth addressing here or very soon after
There was a problem hiding this comment.
@shykes I had codex do a comparison, this PR does indeed seem to massively regress performance of even just dagger install and dagger workspace config:
Setup:
- Checkout size of my dagger repo: 3.9 GB, including a 652 MB
.gitdirectory and large ignored directories. - Each cold measurement started with a fresh engine cache.
- Both versions operated on the same minimal native
dagger.toml.
| Command | upstream/main |
This PR |
|---|---|---|
dagger workspace config check-generated true |
0.99s | 45.19s |
| Host filesystem input | 2.29 MiB | 3.805 GiB |
dagger install ./modules/wolfi |
14.05s | 71.72s |
| Host filesystem input | 0.95 MiB | 3.807 GiB |
That's big enough that I really feel like we should just fix it now before merging. @vito already posted a potential fix above, I think we should just try that.
5251804 to
0b80db2
Compare
3227a5e to
c28b2d0
Compare
4dc6e25 to
bd6f1ee
Compare
| ws, err := Detect(ctx, fakePathExists(existing), "/repo/app") | ||
| require.NoError(t, err) | ||
| require.Equal(t, "/repo", ws.Root) | ||
| require.True(t, ws.HasGitRoot) |
There was a problem hiding this comment.
It could be interesting to have one opposite test somewhere, with a case HasGitRoot == false
There was a problem hiding this comment.
Added TestDetectInRootDoesNotClaimGitRoot, covering an explicit boundary with HasGitRoot == false.
| parent dagql.ObjectResult[*core.Workspace], | ||
| args workspaceUninstallArgs, | ||
| ) (dagql.ObjectResult[*core.Workspace], error) { | ||
| return s.withoutModule(ctx, parent, args) |
There was a problem hiding this comment.
nit: shouldn't this check it's actually removing an SDK?
There was a problem hiding this comment.
Why was this deleted? It doesn't seem like the equivalent test coverage was really replaced in full. Intentional?
There was a problem hiding this comment.
Yes we're moving the SDK-specific tests to the SDK repos
There was a problem hiding this comment.
Okay, I had missed that. Hopefully the tests still run as part of the github.com/dagger/dagger CI though, right? That's a separate conversation though, not a blocker here really.
There was a problem hiding this comment.
Didn't see this test coverage was replaced, why is it deleted?
There was a problem hiding this comment.
Same as client_generator_test.go: moving SDK-specific tests to SDK module repos.
|
Noticed Minimal hang is: dagger call engine-dev test \
--run 'TestWorkspaceAPI/TestWorkspaceSDKReadersUseStagedOverlay' \
--pkg ./core/integrationWhen I run that I see that it gets stuck in a (Confusingly the UI pretends the test 'passed' - I guess because I interrupted it, it never "failed") |
|
This is coming directly from Codex. Erik checked it, and it makes sense to him. Blocker: In dagql.NewObjectResultForCurrentCall(ctx, srv, sdk)At that point the current call is the This is observable with only one SDK: There is a second identity problem behind the hang: if multiple SDK children all reuse the same current call, they are indistinguishable to the cache.
|
The overlay sparse-read design doc described the implementation against the pre-rebase overlay model (stored Root/BaseRoot/DeltaRoot fields). The dagger#13600 update slimmed the overlay to {Base, Changes} with the read root derived from Changes.After, so the fix was re-expressed rather than ported: the delta root lives as Changes.After, the sparse base as Changes.Before, and TouchedPaths is the only added field. Record the reformulation up top — including why TouchedPaths cannot be derived from the changeset (reverted edits would resurface as phantom additions), the SourceDirectory gate that keeps the sparse After from masquerading as the workspace tree, the rootless dispatch hazard (rootless sources carry a host path but must not read through it), why rename detection survives a touched-paths base, and the two lock-read full-sync sites the original design never saw — and rewrite the key code locations to match the as-built shape. The original diagnosis and design reasoning below it still apply and are kept. Signed-off-by: Alex Suraci <[email protected]>
9ad2586 to
0b94829
Compare
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Signed-off-by: Solomon Hykes <[email protected]>
Editing a host-backed workspace forced a filterless host.directory(".")
upload of the whole tree (~11s per Edit() on this repo): the overlay's
changeset was computed against the full host base, its derived read root
(Changes.After) was full host + edits, and Directory.withChanges must
materialize its base, so both edits and reads paid the full sync.
Make the changeset delta-native for host (client-local) overlays instead.
Changes.After becomes the delta root — the accumulated edits applied to an
empty base, never referencing the host tree — and Changes.Before a sparse
host.directory including only the cumulative TouchedPaths, the one field
added to the overlay source. Forcing changes/export then syncs just the
touched files (new files sync nothing), and edits stay in-engine. Renames
survive the sparse base: a removal only ever comes from an edit, so both
sides of a rename are always touched and present in the base.
Since the sparse After must never masquerade as the workspace tree,
SourceDirectory() now returns false for client-local overlays, and reads
resolve per-call instead: a sparse host.directory of just the requested
paths (re-rooted filter, gitignore threaded) with the changeset applied on
top, then descend and trim — untouched files serve host content at read
time, edits win, removals don't resurface. readConfigBytes dispatches on
the touched set so config builders see staged config edits while untouched
configs still read straight from the host file. Whole-tree consumers
(module-source loading, install flows) keep materializing full host +
changeset via workspaceOverlayRootfs, now only when actually requested.
Value, git, and rootless workspaces keep the full-root accumulation: their
trees are already in-engine (empty for rootless), so there is nothing to
upload. Rootless local workspaces carry a host path but must not read
through it, so all dispatch is on the base source kind, not the host path.
Signed-off-by: Alex Suraci <[email protected]>
0b94829 to
6376ba0
Compare
Signed-off-by: Guillaume de Rouville <[email protected]>
The overlay sparse-read design doc described the implementation against the pre-rebase overlay model (stored Root/BaseRoot/DeltaRoot fields). The dagger#13600 update slimmed the overlay to {Base, Changes} with the read root derived from Changes.After, so the fix was re-expressed rather than ported: the delta root lives as Changes.After, the sparse base as Changes.Before, and TouchedPaths is the only added field. Record the reformulation up top — including why TouchedPaths cannot be derived from the changeset (reverted edits would resurface as phantom additions), the SourceDirectory gate that keeps the sparse After from masquerading as the workspace tree, the rootless dispatch hazard (rootless sources carry a host path but must not read through it), why rename detection survives a touched-paths base, and the two lock-read full-sync sites the original design never saw — and rewrite the key code locations to match the as-built shape. The original diagnosis and design reasoning below it still apply and are kept. Signed-off-by: Alex Suraci <[email protected]>
readWorkspaceLockForOverlay materialized the whole workspace tree just to stat and read the lockfile: it went through workspaceOverlayRootfs, which resolves a filterless host.directory for host-backed workspaces — a full upload even on pristine workspaces with no overlay. workspaceLockChangeset had the same problem, diffing its lockfile write against a filterless base. Resolve both against an include-scoped rootfs instead: the lock read requests just the canonical and legacy lock path candidates, and the lock changeset diffs against a base containing only the lockfile — the diff never covers anything else, so the changeset is identical. Host workspaces (pristine or overlaid) now sync only the lock files on install and update flows; value/git/rootless workspaces resolve the same filter in-engine. Signed-off-by: Alex Suraci <[email protected]>
The overlay sparse-read design doc described the implementation against the pre-rebase overlay model (stored Root/BaseRoot/DeltaRoot fields). The dagger#13600 update slimmed the overlay to {Base, Changes} with the read root derived from Changes.After, so the fix was re-expressed rather than ported: the delta root lives as Changes.After, the sparse base as Changes.Before, and TouchedPaths is the only added field. Record the reformulation up top — including why TouchedPaths cannot be derived from the changeset (reverted edits would resurface as phantom additions), the SourceDirectory gate that keeps the sparse After from masquerading as the workspace tree, the rootless dispatch hazard (rootless sources carry a host path but must not read through it), why rename detection survives a touched-paths base, and the two lock-read full-sync sites the original design never saw — and rewrite the key code locations to match the as-built shape. The original diagnosis and design reasoning below it still apply and are kept. Signed-off-by: Alex Suraci <[email protected]>
Reading Workspace.sdks hung indefinitely when the workspace contained an SDK. The integration test TestWorkspaceSDKReadersUseStagedOverlay reproduced the same symptom as the test-workspaces CI timeout: its query stopped inside Workspace.sdks and never returned. workspaceSDKResults created each WorkspaceSDK child with dagql.NewObjectResultForCurrentCall. That helper assigns the resolver's current call to the returned object. In this resolver the current call is the enclosing Workspace.sdks list call, not a call identifying one element of that list. When ObjectResultArray.AttachDependencyResults attached a child to the list, the cache looked up Workspace.sdks while that exact call was still being initialized. The result therefore waited on its own in-progress cache entry. This explains why one SDK was enough to deadlock. It also meant every SDK in a multi-item result shared one call identity, so the cache could not distinguish children with different payloads. Construct each SDK through a new internal Workspace.__workspaceSDK selector, following the established Workspace.__workspaceModule pattern. Select it from the owning Workspace result and pass the SDK name, ref, module names and sources, and client names and sources as selector arguments. DagQL can now derive a deterministic call for each child without referring back to the list call. Including the complete SDK payload in the arguments also ensures that two different SDK entries cannot alias in the cache. Route Workspace.sdk through the same helper so single-item and list reads use one identity model. Add TestWorkspaceSDKsHaveDistinctIdentity with two SDK entries whose refs, authored modules, and generated clients differ. It reads the full list in one query, verifies both payloads, requires non-empty IDs, and asserts that the IDs are distinct. Run it together with TestWorkspaceSDKReadersUseStagedOverlay to cover both regressions: the existing single-SDK query must terminate, and multiple children must remain distinct. Signed-off-by: Guillaume de Rouville <[email protected]>
grouville
left a comment
There was a problem hiding this comment.
LGTM, introduced the cache hit fix
The TestClientGenerator suite was deleted from core/integration in the workspace overlay and export change (#13600). Client generation tests are planned to move to the SDK modules, per future/sdk-tests.md. Since then the test-split/test-client-generator check builds a dev engine and runs go test with a selector that matches nothing: testing: warning: no tests to run ok github.com/dagger/dagger/core/integration 0.066s [no tests to run] Remove the check, its release-branch workflow entry, and the now-dead skip entries in the base and package shards. A future TestClientGenerator suite would run in the base catch-all shard by default. Also drop the release-branch workflow entry for test-split/test-cgroups. That check was split into test-provision and test-telemetry in #11735 and no longer exists. Also point a helper comment that named the deleted suite at TestGenerators, which uses the same helper. Signed-off-by: Erik Sipsma <[email protected]>
Implement the proposed Workspace overlay & export API
Closes #13566
TODO before release
sdk install→api client init→generate→ compile/run. Until then, development builds based on this change do not generate official clients.currentWorkspace.withChanges(...).exportinstead of exporting to.; add coverage for runningdagger generatefrom a nested workspace directory.withoutSDK(name:)through the same module-key/as-sdk.namelookup assdk(name:); test removing an aliased SDK.