Skip to content

go: build for a target platform on any machine, with fewer engine requests per module load (needs Dagger v1.0.0-beta.26) - #100

Merged
sipsma merged 17 commits into
mainfrom
sipsma/go-beta26-platforms
Nov 10, 2026
Merged

sipsma merged 17 commits into
mainfrom
sipsma/go-beta26-platforms

Conversation

@sipsma

@sipsma sipsma commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Builds with this module can target a platform other than the machine's, and a Go module load sends the engine far fewer requests. This needs Dagger v1.0.0-beta.26: gobuild targets that release and builds with its published dagger.io/dagger library, so an older engine can't load it.

These changes were waiting on v1.0.0-beta.26, which ships the engine fields they use. They follow #95.

Builds for a target platform on any machine

  • gobuild builds its tools (gohdr, pack and the archives' write-manifest) for every machine an engine runs on, and declares what it builds for its target platform (Directory.withPlatform). So a build made on one platform is found by an engine of another that builds for the same target, such as an engine image for arm64 prepared on amd64.
  • archiveBuilds takes the platform it builds for. GoArchiveBuilds returns gohdr and write-manifest for every machine, as directories, and gains helperBinary, the includes helper for that platform.
  • Together with the typed archiveBuilds from go: per-package builds that share module downloads and plans, with faster edits, lints and gobuild loads #95, this is what dagger/dagger's engine images use to ship each platform's pre-warmed cache. It also ends the intermittent "missing shared result" those images hit.

Fewer requests per module load

  • A build's dependencies, the packages that read none of its source, are built in one call of their own, which the engine caches. Every build that compiles the same dependencies the same way finds them in one request, whatever its own source.
  • Module discovery is likewise one cached call. The call never downloads a module the project's own source provides.
  • A package's exec and the read of its archive go in one request. The platform declaration is part of the build's own query.
  • Measured on burst machines, each change against the branch before it, interleaved, on fresh engines:
    • a warm Go module load went from 1,870 engine requests to 522, then from 525 to 321;
    • wall time was unchanged within noise;
    • engine CPU on a warm load went from 14.17 s to 13.46 s.
  • Slower: the first edit after a cold call measured 5.17 s against 5.33 s, on 2 runs each, so that's unresolved. A cold load makes about 40 more requests.

Also

  • go-dev's selected-test checks read v1.0.0-beta.26's dagger check report. That report groups a collection's items under their check, and its top header counts the items again.

Merging

Please merge this with a merge commit. Dagger v1.0.0-beta.26's built-in Go SDK builds with a commit in this branch's history, the one tagged pin/dagger-v1.0.0-beta.26. A merge commit makes it part of main.

Testing

  • CI needs a v1.0.0-beta.26 engine. Until its checks run on that release, they fail to load the module.
  • On released v1.0.0-beta.26, dagger/go's whole check suite passed on this tree except 11 selected-test checks, which misread that release's report layout. The last commit fixes them, and all 13 selected-test checks pass with it.
  • dagger generate changes nothing: gobuild's generated files are what the pinned go-sdk generates.

sipsma added 16 commits November 6, 2026 06:41
What a build compiles for a target is the same whichever machine's Go
toolchain compiles it, so each build is declared as made for its target
(Directory.withPlatform): an engine of the target's platform finds the
builds an engine of another platform made for it, such as the ones an
engine image built on another platform ships.

- archives and archiveBuilds take the platform they compile for, the
  engine's when unset.
- Each package's build, but a cgo package's, whose C compiler is the
  machine's, and each module download are declared for the build's target.
- A package's script runs the toolchain's tools from its tool directory for
  the machine the exec runs on, which it reads from the toolchain, instead
  of the plan's, which names the machine that made the plan.
- gohdr, pack and golangci-lint's write-manifest are built for every
  machine an engine runs on, each into one directory with a script that
  runs the exec's machine's: a build mounts the same tools on every
  machine.
- The includes helper is built for the engine's platform by any machine's
  toolchain, and declared for it.
- archiveBuilds' tool and manifestTool are those gohdr and write-manifest
  directories, and its new helperBinary is the includes helper for the
  builds' platform: what an engine image of that platform ships.

Signed-off-by: Erik Sipsma <[email protected]>
…r a given platform

gobuild requires dagger.io/dagger v1.0.0-beta.26, the release it targets,
and replaces it with v1.0.0-beta.25 until that release publishes its
library; its generated entrypoint is regenerated for the target.

Signed-off-by: Erik Sipsma <[email protected]>
A package's script went in as a file made for it and mounted, and the
client asked the engine for that file's ID in a request of its own before
the step's request could mount it: one request and two calls more for
every package. On the exec's standard input, the script is part of the
exec's own call.

Signed-off-by: Erik Sipsma <[email protected]>
v1.0.0-beta.26's dagger.io/dagger library isn't published yet, and gobuild
needs its bindings, such as Directory.withPlatform and File.sync's
keyByContent. Until the release, gobuild builds with that library as the
engine's pull request has it, as a Go module at a fixed commit. The
follow-up pull request after the release requires the published library.

Signed-off-by: Erik Sipsma <[email protected]>
Each package's build, each module download and each tool directory is
declared for its target with the library's Directory.withPlatform, in the
same query that builds it, instead of asking the engine for the result's
ID and then sending a query of its own for the declaration: two requests
for every package, cached or not.

Signed-off-by: Erik Sipsma <[email protected]>
A package's step evaluated its exec's output directory in one request and
read its archive from it in a second, so that the archive was keyed by its
content. File.sync's keyByContent keys it in the request that runs the
exec, so each dependency level of a build waits on one request, not two.
The link object a split package's link reads is keyed the same way, still
after its importers start.

Signed-off-by: Erik Sipsma <[email protected]>
…writes

A package's script went to its exec on its standard input, which the
step's title shows, so a failed compile's title was the whole script. The
step's container now writes it as a file in the step's own query, and the
exec names the package, as before the script went to standard input, still
without the request a mounted file object cost for its ID.

Signed-off-by: Erik Sipsma <[email protected]>
…eeps returned IDs

The engine's pull request now has core.Loaded, which builds an object
from an ID the engine returned knowing it, and go-sdk's bindings use it for
the core objects a request returns, for modules that target
v1.0.0-beta.26. gobuild builds with that library and is generated by that
go-sdk, so each File a list field of its own returns keeps its ID.

Signed-off-by: Erik Sipsma <[email protected]>
Every load of a Go module walked every package its build compiles, the
standard library and dependencies included, with a request or two to the
engine for each, even when every package was cached: about 1,300 requests
of a warm load's 1,900. The packages that read none of the build's source
and import nothing that does are now built by Dependencies, which the build
calls through the engine with exactly what they read: their nodes by their
stable names, the base, the tools, the platform and the downloaded modules'
directories. The engine caches the call, so every build that compiles the
same dependencies the same way finds them in one call, whatever its own
source, and an edit of that source leaves the call as it is. Inside the
call, each package is still its own exec, keyed by what it reads, so a new
dependency set re-runs only what changed.

Signed-off-by: Erik Sipsma <[email protected]>
…ovides

The build follows a dependency's import of a package of its own source
into the source, and never downloads the module version go.sum may also
name for it. The discovery call has no source, so it followed such an
import into that version, and a download that failed there, of a version
no longer served or with no network, failed a build that discovers on its
own. The call is now given the source's modules that go.sum may provide a
package of, nearly always none, so its key stays the same for every module
with the same dependencies; it neither downloads nor follows their
packages, and reports them as followed, and the build then discovers on its
own, as it does when the call followed a package of its source.

Signed-off-by: Erik Sipsma <[email protected]>
…n module

A dependency's package that imports one of the project's own packages is
built with the project's, which the build reaches only by following the
import into its source. The check builds such a project from a file proxy,
and again with a go.sum that also names a version of the project's module
that no proxy serves, which the build must not download.

Signed-off-by: Erik Sipsma <[email protected]>
Since dagger/dagger#15088, `dagger check` reports a collection's items
under one check: the report's top CHECKS header counts the collection
once, and the items' totals move to the CHECKS header nested under it.
The selected-test checks compared the top header with the items'
totals, so 11 of them failed on an engine with that change even though
every item reported the expected result.

Accept both layouts: the released engines' flat report, whose one top
header tallies the items, and the grouped one, whose top header shows
one collection check, passed only when every item passed, with exactly
one header nested under it that tallies the items.

Signed-off-by: Erik Sipsma <[email protected]>
v1.0.0-beta.26 is released, and its dagger.io/dagger library is published,
so gobuild requires it as it is and the replace that stood in for it, the
library from the release's pull request, goes. The workspace pins go-sdk at
the commit its pull request merged as, which generates gobuild's files as
the earlier pin did; regenerating changes only go.sum and the lock, which
records the sdk-helpers release that go-sdk now uses.

Signed-off-by: Erik Sipsma <[email protected]>
v1.0.0-beta.26's dagger check groups a collection's items under its check
as main's report does, but its top header counts the items again, not the
one collection check. checkSummaryMatches read only the two layouts before
it, so every selected test check failed on that release with the totals it
expected. A grouped report's top header may now count either.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma merged commit e722cfc into main Nov 10, 2026
1 of 33 checks passed
sipsma added a commit to dagger/dagger that referenced this pull request Nov 10, 2026
The engine image's entries call each Go module's prebuild with the
platform it builds for, which dagger/go's gobuild takes since its
per-platform build merged (dagger/go#100). The built-in Go SDK pinned a
dagger/go main from before that merge, whose prebuild takes no platform,
so the entries failed. It now pins dagger/go's main with that merge and
with gomod's beta.26 type names kept distinct (dagger/go#102), and go-sdk
moves to the commit that names the same dagger/go (dagger/go-sdk#103), as
the entries require. The workspace's own dagger/go module stays where it
was: the checks' engine loads it, and that engine is older than the
per-platform build needs.

Signed-off-by: Erik Sipsma <[email protected]>
dagger-ci pushed a commit to dagger/dagger-go-sdk that referenced this pull request Nov 10, 2026
The engine image's entries call each Go module's prebuild with the
platform it builds for, which dagger/go's gobuild takes since its
per-platform build merged (dagger/go#100). The built-in Go SDK pinned a
dagger/go main from before that merge, whose prebuild takes no platform,
so the entries failed. It now pins dagger/go's main with that merge and
with gomod's beta.26 type names kept distinct (dagger/go#102), and go-sdk
moves to the commit that names the same dagger/go (dagger/go-sdk#103), as
the entries require. The workspace's own dagger/go module stays where it
was: the checks' engine loads it, and that engine is older than the
per-platform build needs.

Signed-off-by: Erik Sipsma <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants