Repository navigation
Conversation
A copy of one content-keyed directory into another now gets a content digest made from both directories' digests and the copy's arguments, as a Dockerfile COPY already does. A directory put together from content-keyed parts, such as two workspace reads, then stays content-keyed, and what is read from it afterwards, such as a subdirectory, is keyed by what it holds rather than by every part it was made from. The digest comes from the inputs' digests, so the copy stays lazy. Signed-off-by: Erik Sipsma <[email protected]>
Contributor
Author
|
Its commits moved into #15007, which now combines the engine's pending performance changes, to save CI runs. |
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.
A directory put together from two content-keyed directories with
withDirectoryloses its content key. Whatever is read from it afterwards, a subdirectory or a filter, is then keyed by the recipe of every part. So a change to any file in either part re-keys every read from the result, even of files that didn't change.This matters for dagger/go, the Go module. Every build there reads the workspace from the client twice, one read after the other. The first read is for the package scan; the second reads the build's source, with the patterns the scan found. Both use patterns like
**/*.go, so each read walks the client's whole tree. A dagger/go change reads the Go files once, for both, then reads again only what is left, such as embedded files, and merges the two reads withwithDirectory. The build keys each package's compile on that package's own files, read from the merged source withdirectoryandfilter. Without this change, every edit would rerun every package's compile.What it does
Directory.withDirectorynow gives its result a content digest when the parent and the source both have one. The digest is made from both digests and the copy's arguments: path, owner, permissions, include, exclude and gitignore. An unfiltered Dockerfile COPY is already keyed this way, in__withDirectoryDockerfileCompat. Since the digest comes from the inputs, the copy stays lazy. When either side has no content digest, nothing changes.The first
directoryorfilterread from such a directory evaluates the copy and content-hashes what it selects. That's what happens today under a host directory.Numbers
These are builds of dagger's CLI with dagger/go: this change plus the dagger/go change, against neither. 4 runs each, alternating, on one c8gd.4xlarge, with a fresh engine per run.
On the build call's critical path, reads from the client fall from 0.33 s to 0.01 s on an edit. What it costs instead is content-hashing the merged source on each edit, 0.22 s on the path. A host directory gets its hashes from the sync; the merged directory has to hash its files again.
On its own, this change doesn't change any dagger/go build. It's what the dagger/go change needs.
Tests
TestDirectory/TestWithDirectoryContentKeyed: a command over a subdirectory of a merged directory stays cached when a file elsewhere in the directory changes. It fails without the change.