Skip to content

perf(go): discover test names within each package - #68

Closed
grouville wants to merge 1 commit into
dagger:mainfrom
grouville:perf/review-package-test-discovery
Closed

grouville wants to merge 1 commit into
dagger:mainfrom
grouville:perf/review-package-test-discovery

Conversation

@grouville

@grouville grouville commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Listing a package's tests currently reads matching functions across its whole Go module, then keeps that package's files. Listing every package repeats that work. In a 16-package fixture, the same 129 matching lines are read 16 times.

Search only each package's direct test files instead. The module-wide search that discovers package paths stays as it is. This keeps Workspace.search, the test matcher, filename ordering and directory traversal. The production change is 12 lines, with no new cache or public API.

This is part of the work to improve Go collection listing. The branch is rebased on Go main c25c457, including #74 and #76, and the filename, overlay and selected-test regression checks pass with that version. The timings below use the earlier pinned versions; a full-listing speedup against #74/#76 is not established yet.

After the discovery changes in #72 and #73, on engine main e7f0bd65, the complete 16-package listing improves from 6.65 to 3.96 seconds across four pairs.

I also checked whether the change still helps with Erik's newer parser. For the table below, both versions use engine main 14c1942e with the parser update from vito/dang#204. That parser has merged upstream but is not yet pinned by the engine. The module baseline is Go main bf45651; only this PR differs between the two columns.

dagger check --module go --check test --list --all
Listing fixture Go main This PR
16 packages, 129 tests 5.42 s 3.35 s
64 packages, 513 tests 50.40 s 11.92 s
One package, nine tests in one file 1.32 s 1.37 s
One package, 129 tests in 16 files 1.79 s 1.92 s

Each row is the median of four pairs, alternating which version runs first. These are complete commands, including session cleanup, after an ordinary-source edit and adding a unique test. Each starts a fresh CLI on an already running engine, after a successful untimed preparation. All 32 measured commands returned the expected rows in order and cleaned up successfully. No outside Go builds overlapped them.

For 64 packages, engine CPU use falls from 264.47 to 66.08 CPU-seconds, and cumulative allocation from 39.78 to 10.35 GB. For 16 packages, allocation falls from 4.78 to 2.83 GB. These are bytes allocated over the command, not peak memory usage.

There is little to save with one package. The controls are about 50 ms and 128 ms slower in this sample, with allocation changing by less than 1%. Those costs remain in the results; this PR is useful when listing tests across many packages.

Separate wcprof captures of the 16-package case on the original engine baseline show matched-line reads falling from 2,064 to 129, while workspace searches stay at 18 in both versions. This removes repeated processing of other packages' matches without skipping discovery.

The runs use normal telemetry and GC, profiling off, Go 1.26.6, eight engine CPUs and a 40 GiB memory limit on a shared Linux host. Both sides use the same CLI, including a separate local stdout-buffer fix. The table has no other unmerged engine or Go performance changes.

The full dagger/dagger workload selects the root Go module at ff0b029a, with 4,398 existing tests plus the added test. The table covers the smaller fixtures, not a full-repository speedup. Full commands that time out, return incomplete output or fail cleanup are excluded.

The filename, overlay and existing collection checks pass. They cover Unicode names, bracket characters in filenames, mounted workspaces, added files and packages, nested modules, ordering and selected test execution. The SDK race checks also pass with the newer parser.

dagger api call -m .dagger/modules/go-dev package-search-filenames-check
dagger api call -m .dagger/modules/go-dev package-search-overlay-check
dagger api call -m .dagger/modules/go-dev tests-collection-check

@grouville
grouville force-pushed the perf/review-package-test-discovery branch from 4208c62 to bc0d99e Compare October 19, 2026 23:46
@grouville grouville changed the title perf(go): search only a package’s own test files perf(go): discover test names within each package Oct 19, 2026
@grouville
grouville force-pushed the perf/review-package-test-discovery branch from bc0d99e to af01bbf Compare October 21, 2026 19:47
Listing a package's tests reads matching lines from the whole Go module, then keeps only that package's files. Listing every package repeats the processing of those module-wide results.

Search only the package's direct test files. Keep the existing matcher, filename order and directory traversal, including literal filenames and symlink handling. The files-only search used to discover package paths stays module-wide.

Cover Unicode names, bracket characters in filenames, mounted workspaces, and files and packages added through Dagger. Keep the existing collection checks for nested modules, ordering and selected test execution.

Signed-off-by: Guillaume de Rouville <[email protected]>
@grouville
grouville force-pushed the perf/review-package-test-discovery branch from af01bbf to b3631f1 Compare October 23, 2026 07:55
@tiborvass

Copy link
Copy Markdown
Contributor

Closing in favor of #81

@tiborvass tiborvass closed this Oct 27, 2026
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