test: share package builds before parallel test runs - #2234
Conversation
There was a problem hiding this comment.
Review: share builds before parallel runs
Reworks llgo test to build all native test binaries once inside build.Do and then run them concurrently (runNativeTestPrograms/runTestPrograms), replacing the old fork-a-child-llgo-test-per-package model. The rewrite is clean: the worker pool, buffered result channel (sized to parallelism), fail-fast/skip accounting, and edge-case guards (empty slice, parallelism==0 → GOMAXPROCS, <1 → 1, clamp to len) all check out, and the removed LLGO_TEST_PARALLEL_WORKER / go list / child-arg machinery leaves no stragglers (verified by grep). TestRunSequential is wired only for the process-wide-output flags plus -fuzz, matching the prior guard, and the new unit tests cover concurrency limiting, fail-fast, and JSON output.
A couple of inline nits on comment wording. One non-blocking design note:
- Serial build, then parallel run. Compilation and linking in
Doremain sequential; only the run phase is now parallelized. The win is deduping shared-dep builds (e.g.testingbuilt once), but for compile-dominated suites the now-serial build phase becomes the bottleneck versus the old fully-concurrent per-package pipeline. Worth a benchmark on a multi-package suite; overlapping run-as-linked could recover throughput if the build phase dominates. Not a blocker.
No correctness, security, or regression issues found in the concurrency mechanics.
| } | ||
| } | ||
| func testRunsMustBeSequential() bool { | ||
| // These flags name process-wide output files. Until LLGo merges or |
There was a problem hiding this comment.
The comment says these flags "name process-wide output files," but flags.TestFuzz (added on line 90) is not an output-file flag — fuzzing forces sequential execution for a different reason (a fuzz run drives a single target and can't be sharded across concurrently-running binaries). Consider adjusting the wording, e.g. "These flags name process-wide output files, or (for -fuzz) require a single active test binary."
There was a problem hiding this comment.
Addressed in 08bc69d: the comment now distinguishes shared output paths from flags such as -fuzz that require one active test binary.
| BuildParallelism int | ||
| LinkOptions LinkOptions | ||
| // TestRunSequential disables concurrent test binary execution for test | ||
| // flags that write to a shared process-wide output file. |
There was a problem hiding this comment.
Same wording gap as testRunsMustBeSequential in cmd/internal/test/test.go: TestRunSequential is also set for -fuzz (see test.go:90), which does not "write to a shared process-wide output file." The stated rationale doesn't cover the fuzz trigger that actually sets this field.
There was a problem hiding this comment.
Addressed in 08bc69d: the comment now distinguishes shared output paths from flags such as -fuzz that require one active test binary.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
The first CI run exposed an existing order-dependent generic ABI symbol issue after this PR began loading all roots together. I pushed Local validation includes the exact 96-package primary macOS shard with a cold LLGo build cache ( |
|
All required checks are green on Latest Actions
The timings confirm the intended shared-build behavior but not a wall-time improvement for compile-heavy shards: build/link remain sequential and no longer overlap test execution. Parallel build work remains outside this PR. @fennoai please review the final changes, including the generic basic-alias ABI canonicalization and added runner coverage. |
Review: shared build before parallel test runsI checked out Verdict: looks good. The refactor is well-structured, the ABI canonicalization is correct and minimal, and the new tests give strong coverage of the scheduling edges. No blocking issues found. A few observations below, all non-blocking. Architecture — restoring the single multi-root
|
Summary
llgo testfan-out introduced by test: parallelize llgo test packages #2193build.Docall so package loading, SSA construction, compilation, and linking share the union dependency graph-p-failfast, JSON output, and sequential handling for shared profile/fuzz output filesbyte/uint8andrune/int32generic ABI symbols, removing an order-dependent mismatch exposed by multi-root loadingPackage compilation and test-main linking remain sequential. This PR does not implement parallel builds; it only parallelizes execution after every requested test binary has been built.
The multi-package runtime regression test verifies that four test roots share one build of the common
testingpackage and then report all four test results. Focused tests cover the native runner success, exit-error, and start-error paths.Validation
-p=4: all links completed before parallel execution; all passed in 1077scrypto/ed25519,unique, andweakmulti-root link and runtime regression passedgo test -race ./cmd/internal/test ./internal/goflagsgo test -race ./internal/build -run '^TestRun(NativeTest|TestPrograms)' -count=1\n-go test ./cmd/internal/...\n-go test ./internal/build -count=1\n-go test ./ssa -count=1\n- focusedssa/cltpnamed golden tests\n-go vet ./cmd/internal/test ./internal/build ./ssa/abi\n-go run ./cmd/llgo test -p=2 ./cl/_testgo/runextest/bar ./cl/_testgo/runextest/foo\n