Repository navigation
fix: keep the module's source out of an entrypoint install's cache key - #145
Merged
Merged
Conversation
A call on a module whose source changed reinstalled its dependencies: 14-20s against 3.5s for a call that changed nothing, on a node module with remoteCoreLib on, where the install pulls five published packages. The recipe already read the manifest and clients/ alone and said so, and it still reinstalled for an edit of a file nothing in the install reads. Two inputs carried the module's source digest into the install exec, and removing one alone changes nothing. The exec itself: the engine attaches the module to a *nesting* exec so that currentModule works in the process an entrypoint starts for a call (dagger/dagger#14767), and an entrypoint's execs all nest by default, so the install carried the module as a second cache input. Read from the engine's own cache snapshot (/debug/dagql/cache on the debug port): the install's result_call_input_digests held two entries, one of them Module. None of these steps calls Dagger, so every setup exec — the image's packages, the loader, the install — now opts out of nesting, and the input is gone. The dispatcher keeps nesting: it runs the module's own code. The read of the manifest: `withDirectory(currentModule.source, include: [...])` filters inside the read, so what it depends on is still the module's source directory, whose digest moves on any file in it. Directory has no content keying to ask for, so installContext assembles the manifest and the clients file by file, each synced with keyByContent — dagger/go's toolSource pattern (dagger/go@4beea52), for the same reason. A file keyed by its content is the same result for any source holding the same bytes at the same path, so the install follows the manifest and the clients, and two modules with the same dependencies now share one install. Measured against the same engine and the same module, one source edit per round: 20.3, 15.5, 15.4, 15.5, 14.4s before, 10.3, 10.8, 10.4, 9.3, 9.4s after. The cache snapshot shows one install exec and one apk add for the whole run of edits, where before each edit made its own. What is left is the dispatcher, which has to run: the module's code changed. The resource path keeps its context read, and its shortcut comment: a read that names no paths has nothing to content-key. Signed-off-by: Tom Chauveau <[email protected]>
…y too The install for a module that imports from outside its own directory still ran again for every source edit. It read the module context — `currentModule.contextDirectory.filter(exclude: [sourceSubpath + "/**"])` — and a read of the context is keyed by the context, module source and all, so the content keying of the commit before this one could not reach it. That is what its shortcut comment said. Both halves of that install now read file by file: the manifest and the clients off currentModule.source, as the path without resources already did, and the resources off the context, each file synced with keyByContent. Nothing in the chain depends on a directory whose digest moves with the module's source. What is left per edit is one glob of the context; the reduce over its result is keyed by content at every step, so it hits cache. Resources are derived rather than declared (importedResources), so this is the path every module importing a sibling directory takes, declaring nothing. Verified by runtimes:include-runs, which generates the fixture, installs it and runs its check for real, and by runtimes:include-cache-key, which pins that rewriting an included file still invalidates the call: content keying must not make a stale read reachable. No speed-up is measurable on that fixture — it declares no dependencies on purpose, so its install has nothing to do, and 11s before against 12s after is the noise. The mechanism is the one measured on the path without resources. shortcut: a file list carries no symlink and no empty directory, where the context read it replaces did. Upgrade when a resource tree needs one. Signed-off-by: Tom Chauveau <[email protected]>
`sync(keyByContent:)` is a view-gated argument (`AfterVersion("v1.0.0-beta.26")`
in the engine's core/schema/file.go), and an entrypoint's dang.toml is what
selects the view its recipe is inferred against. So the recipe has a floor now,
and a module whose entrypoint/dang.toml pins under it — or leaves the Dagger
import unversioned, which resolves to the default view, where `File.sync` has no
arguments at all — cannot be loaded.
`e2e/version/dang-config-check` is where that lands. It writes `dagger = true`
into a settled module and regenerates, expecting the pin to be healed; but
generation loads the module through the recipe before it can rewrite the file, so
the engine's inference error arrives instead of the heal.
The heal is still asserted for every pin the recipe can be loaded under, from the
floor rather than from beta.19 or `true`. What is no longer possible is asserted
in its place, for both spellings, so the next person to raise the floor meets a
test naming the cost rather than an inference error with no owner. The `spelled`
case pins the release outright: an Engine alias spelling the release beside a
Dagger import pinned lower is refused in its own right, two Dagger versions in
one file.
The recipe's own header named v1.0.0-beta.18, the release declaring `sources`
took. It names the real floor now, and what a module under it cannot do.
Signed-off-by: Tom Chauveau <[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.
A call on a module whose source changed reinstalled its dependencies. The recipe
already read the manifest and
clients/alone and said so in its docstring, andit still reinstalled for an edit of a file nothing in the install reads: 14-20s
against 3.5s for a call that changed nothing, on a node module with
remoteCoreLibon, where the install pulls five published packages.Two inputs carried the module's source digest into the install exec, and removing
one alone changes nothing.
The exec itself. The engine attaches the module to a nesting exec so that
currentModuleworks in the process an entrypoint starts for a call(dagger/dagger#14767), and an entrypoint's execs all nest by default — so the
install carried the module as a second cache input. Read from the engine's own
cache snapshot (
/debug/dagql/cacheon the debug port): the install'sresult_call_input_digestsheld two entries, one of themModule. None of thesesteps calls Dagger, so every setup exec — the image's packages, the loader, the
install — now opts out of nesting. The dispatcher keeps nesting: it runs the
module's own code.
The read of the manifest.
withDirectory(currentModule.source, include: [...])filters inside the read, so what it depends on is still the module's source
directory, whose digest moves on any file in it.
Directoryhas no contentkeying to ask for, so the install context is assembled file by file, each synced
with
keyByContent— dagger/go'stoolSourcepattern (dagger/go@4beea52), forthe same reason. A file keyed by its content is the same result for any source
holding the same bytes at the same path, so the install follows the manifest and
the clients, and two modules with the same dependencies share one install.
The second commit does the same for a module that imports from outside its own
directory, where the install read the module context instead — and a read of the
context is keyed by the context, module source and all. Resources are derived
rather than declared (
importedResources), so this is the path every moduleimporting a sibling directory takes, declaring nothing.
Measured
Same engine, same module, same workspace; one source edit per round,
dagger call -m test base-image-address.On the resource path, isolating the second commit: 8 / 8 / 9s before against
6 / 5 / 6s after.
The cache snapshot corroborates both halves rather than the clock: four calls
made four installs before and one after, while the dispatcher re-ran for
every one of them — as it must, the module's code having changed. That dispatcher
is what the remaining time is.
Verified
runtimes:include-runsgenerates the resource fixture, installs it and runs itscheck for real, and
runtimes:include-cache-keypins that rewriting an includedfile still invalidates the call — which is what content keying must not quietly
break. Both pass. Neither measures anything: that fixture declares no
dependencies on purpose, so its install has nothing to do.
Left behind
shortcut:a file-by-file install context carries no symlink and no emptydirectory, where the context read it replaces did.
Needs Dagger v1.0.0-beta.26 or later for
sync'skeyByContent, which thedang.tomlgenerated beside the recipe pins.