Repository navigation
Conversation
sipsma
force-pushed
the
sipsma/thp-opt-in
branch
from
October 30, 2026 19:02
d509142 to
4c57214
Compare
…e pages The kernel can switch transparent huge pages off for a process, never on, and a process passes the setting on to the processes it starts. So on a host set to "always", every exec now starts with them off except where its program asks for them (PR_THP_DISABLE_EXCEPT_ADVISED, Linux 6.18), as on a host set to "madvise", unless the exec sets transparentHugePages. The engine sets the mode on itself while the runtime starts, under a lock, and puts its own mode back once the runtime has started. Kernels before 6.18 lack the mode; there nothing changes. Signed-off-by: Erik Sipsma <[email protected]>
A field's schema can mark an argument volatile: its value goes to the resolver, but not into the call's cache identity, its ID or its telemetry. Calls that differ only in it are the same call, and share whichever result was made first. It is for arguments that cannot change the result, such as a performance hint, and needs a default. Signed-off-by: Erik Sipsma <[email protected]>
The setting cannot change what an exec produces, so an exec that differs from a cached one only in it reuses the cached result. Signed-off-by: Erik Sipsma <[email protected]>
…, and says what the default keeps Older views keep the schema they had. The documentation said commands get no huge pages without the setting; they still get them for memory their own program asks huge pages for, and a host's per-size settings count as well as its top-level one. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
… page size's Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
sipsma
force-pushed
the
sipsma/thp-opt-in
branch
from
October 30, 2026 21:19
4c57214 to
58052d9
Compare
… the complexity limit 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.
Adds
withExec(transparentHugePages: true), which lets a command use the Linux kernel's transparent huge pages. Every other command now starts with them off, except for memory its own program asks huge pages for.Why
Large-memory programs such as the Go compiler spend a lot of their time in page faults. With 2 MiB huge pages, a cold first build of the dagger CLI, built one package per exec, ran 2.6 s faster (24.7 s → 22.1 s). An edit-and-rebuild ran 0.8 s faster. Measured on an AWS c8gd.4xlarge (Graviton4, 16 cores), Linux 7.0, medians of 4 runs. The machine's system CPU over the first build fell from 48 to 33 CPU-seconds.
The kernel can't turn huge pages on per process. A process can only turn them off for itself (
PR_SET_THP_DISABLE), and the processes it starts inherit that. So a host set toalwaysgives them to every container, including programs that don't benefit and pay for them in memory. This PR makes them an opt-in per exec: on a host set toalways, an exec gets them only if it asks.What changes
Runfor an exec andExecfor a command in a running container, the engine sets its own mode under a lock. Execs that didn't opt in get "off except where advised" (PR_THP_DISABLE_EXCEPT_ADVISED, Linux 6.18). Execs that did get the mode cleared. Once the runtime has started, the engine puts its own mode back. The runtime and the container keep the mode they started with.withExec(transparentHugePages:), in views from v1.0.0-beta.22.Who sees a difference
madvise, and no page size under/sys/kernel/mm/transparent_hugepage/hugepages-*set toalways): nothing changes. Measured on the same machine, the first build and both edits were within 0.3 s with and without the change.always(or with a page size set toalways), Linux 6.18 or later: execs no longer get huge pages unless they opt in. Programs that ask for them themselves (madvise(MADV_HUGEPAGE)) still get them.With the host at
always, opting in only the Go compiles and links got the same build time as giving every exec huge pages (within 0.15 s).Tests
TestVolatileArg(dagql): calls that differ only in a volatile argument run once and share the result. The resolver sees the value it ran with, and the ID doesn't carry the argument. A dynamic-input hook keeps the value, and a non-volatile argument still tells calls apart.TestStartWithTHP(engine/engineutil): the runtime starts with the mode its exec asked for, the pid reaches the caller, and the engine's own mode is put back, also when the start fails. It skips on kernels before 6.18.TestContainer/TestTransparentHugePages(core/integration): an exec and its children read back mode 0 with the opt-in, and 3 without it on 6.18+. The same command with and without the setting runs once.TestBaseSchemaAllowlist: the argument isn't in older views.