Skip to content

Cut per-package module calls from package discovery - #73

Merged
sipsma merged 2 commits into
mainfrom
perf/discovery-2
Oct 21, 2026
Merged

sipsma merged 2 commits into
mainfrom
perf/discovery-2

Conversation

@sipsma

@sipsma sipsma commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

This continues the discovery work from #72, which made package discovery much cheaper on large repositories. Two commits:

Package paths and selections in process. Go.packages called into the gomod module for small string work. It made one call per package directory to join the module path and the directory (GoMod.subpath). It made more calls to check build and test selections against patterns (GoMod.selected). Each call from this module into gomod has a fixed cost of roughly 60 to 150 ms, mostly setting up the call, for a few string operations. On the dagger repository, with 810 packages, that adds up. These now run in this module, with the same rules as gomod's normalize, subpath, selected and matches.

No generate selection without go:generate commands. For each module, discovery checked its go:generate packages against the generate patterns. That globs the workspace once per pattern, even when the module has no go:generate commands, which is most modules. It now skips that step when there is nothing to select. The result is the same.

The module loads and discovers yq's packages on a released engine, with the same keys before and after each commit, and builds yq's binary.

Numbers

Discovery alone (packages | keys) on a snapshot of the dagger repository, 80 Go modules and about 4,000 Go files. Before is dagger/go main with #72 and #71; after is this PR. Both ran on one Dagger Cloud engine with the beta.19 CLI running inside it, three runs each, and all returned the same 810 package keys.

before after
Runs after the first 60 s, 52 s 24 s, 28 s
First run 411 s 19 s

The first run of each is not a fair comparison: this PR ran second, on an engine already warmed by the runs before it. The later runs are the comparison. They are one set of runs on a shared engine, so a few seconds either way is noise. Discovery runs on every build call, so on the dagger repository this saves about the same time on each edit and each no-change build.

Package discovery called into gomod for a string join for every package
directory (GoMod.subpath), and for a pattern match for every main package
and every module's test setting (GoMod.selected). Each is a module call,
with the fixed per-call cost of one; with a cold cache, as on a first
build, the dagger repository's 810 packages made hundreds of them. They
now run in process, as gomod's own code does them.

Signed-off-by: Erik Sipsma <[email protected]>
Finding a module's go:generate packages globbed the whole workspace for
each generate pattern, for every module, even when the module has no
go:generate command to select from, as most don't. It now skips that
when there is nothing to select.

Signed-off-by: Erik Sipsma <[email protected]>
@grouville
grouville self-requested a review October 21, 2026 19:19
@sipsma
sipsma merged commit bf45651 into main Oct 21, 2026
52 checks passed
sipsma added a commit to sipsma/dagger that referenced this pull request Oct 21, 2026
…retries

The golang workspace module (generate and test checks) still used
dagger/go's pull/45 head, which is frozen at its September merge. Pin it
to the dagger/go main merge of dagger/go#73, which also contains
dagger/go#71 and dagger/go#72:

- dagger/go#71 sets GOPROXY to proxy.golang.org|proxy.golang.org|direct
  in withGoCaches, so a module zip download that the proxy resets
  mid-stream is retried once against the proxy and, on another proxy
  failure, attempted directly from the origin. The check can still fail
  if that fallback fails.
- dagger/go#72 and dagger/go#73 speed up and fix package discovery.

The source names a commit rather than main because dagger.lock pins are
not applied in Cloud's remote-workspace sessions, so main would float in
CI. The dagger/go main entry in dagger.lock is refreshed to the same
commit with dagger lock update.

dagger/go now organizes checks and generators by package, so their names
change: golang/generate-all/stale becomes golang/packages/generate/stale,
golang/test-all becomes golang/packages/tests/test, and the
golang/generate-all generator becomes golang/packages/generate. Update
the release instructions' generate step to the new generator name.

Signed-off-by: Erik Sipsma <[email protected]>
sipsma added a commit to sipsma/dagger that referenced this pull request Oct 21, 2026
…retries

The golang workspace module (generate and test checks) still used
dagger/go's pull/45 head, which is frozen at its September merge. Pin it
to the dagger/go main merge of dagger/go#73, which also contains
dagger/go#71 and dagger/go#72:

- dagger/go#71 sets GOPROXY to proxy.golang.org|proxy.golang.org|direct
  in withGoCaches, so a module zip download that the proxy resets
  mid-stream is retried once against the proxy and, on another proxy
  failure, attempted directly from the origin. The check can still fail
  if that fallback fails.
- dagger/go#72 and dagger/go#73 speed up and fix package discovery.

The source names a commit rather than main because dagger.lock pins are
not applied in Cloud's remote-workspace sessions, so main would float in
CI. The dagger/go main entry in dagger.lock is refreshed to the same
commit with dagger lock update.

dagger/go now organizes checks and generators by package, so their names
change: golang/generate-all/stale becomes golang/packages/generate/stale,
golang/test-all becomes golang/packages/tests/test, and the
golang/generate-all generator becomes golang/packages/generate. Update
the release instructions' generate step to the new generator name.

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