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.
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
|
ca23d80 to
14c1bb0
Compare
LLGo baseline benchmarks
Program measurements
Core language and compiler benchmarks
Compared with |
|
Rebased scope update: current The earlier review/timing note that package compilation remained serial is therefore obsolete; the PR description and phase-boundary comment have been updated. Focused @fennoai please review the integration with the existing #2182 package scheduler at the current head. |
Review: integration with the #2182 package schedulerReviewed the fixed range What checks out
One behavior change worth a conscious decision (non-blocking)
Verification
Overall: the orchestration change integrates cleanly with the #2182 scheduler, the test coverage for the new runner is thorough, and the ABI canonicalization is correct. The only item I'd surface is the reduced build-failure fault isolation across multi-root test runs — confirm that trade-off is intended. |
|
Confirmed: the reduced per-root build-failure isolation is an intentional trade-off for this PR. The current I added a Behavioral trade-off section to the PR description documenting that load/compile/link failure in any root prevents all native test binaries from running, and that |
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 execution for shared profile/fuzz output modesbyte/uint8andrune/int32generic ABI symbols, removing an order-dependent mismatch exposed by multi-root loadingPhase ownership
multi-root load/SSA -> parallel package backends (#2182, bounded by -p) -> sequential test-main links -> parallel native test execution (this PR, bounded by -p)The current
mainstill fans multi-package tests out to childllgo testprocesses and forces each child to-p=1. Moving those roots back into onebuild.Docall lets the existing #2182 scheduler build their union dependency graph in parallel while compiling shared packages such astestingonly once.This PR owns test orchestration and execution scheduling. Test-main linking remains sequential because it consumes coordinator-owned whole-program state. The generic basic-alias ABI fix remains a separate commit in this PR because the single multi-root load exposes that latent symbol mismatch.
The multi-package runtime regression verifies that four test roots share one build of the common
testingpackage and report all four test results. Focused tests cover native runner success, exit-error, start-error, concurrency bounds,-failfast, JSON output, and forced sequential execution.Behavioral trade-off
The shared multi-root build has invocation-level failure semantics. If package loading, backend compilation, or test-main linking fails for any root,
build.Doreturns beforerunNativeTestPrograms, so tests for other successfully built roots are not run. This intentionally trades the per-package fault isolation of #2193 for one shared union build. Preservinggo test ./...-style partial progress would require root-aware build errors and scheduling and is outside this PR.Validation after rebasing onto #2182
go test ./internal/build -run '^(TestExtest|TestRunNativeTest|TestRunNativeTestProgramsSequential|TestRunTestPrograms.*)$' -count=1go test ./cmd/internal/test ./ssa/abi -count=1go test ./cl -run '^TestRunAndTestFromTestgo/tpnamed$' -count=1The pre-#2182 timing comparison is intentionally removed because it measured a branch where package backend compilation was still serial and is no longer representative of this PR on current
main.