Skip to content

perf(ci): shard sanitizer legs, LPT-pack test waves, and parallelize Step 0/5 & TSan - #3220

Open
GDemay wants to merge 1 commit into
DeusData:mainfrom
GDemay:perf/ci-test-harness-sharding
Open

GDemay wants to merge 1 commit into
DeusData:mainfrom
GDemay:perf/ci-test-harness-sharding

Conversation

@GDemay

@GDemay GDemay commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

PR authored with AI assistance on behalf of @GDemay; the commit carries Guillaume's DCO sign-off.

What does this PR do?

Split out from #3210 per maintainer review (Piece 2: test harness, sharding, wave runner, Step 0/5 parallelism, worker caps). Standalone on main, incorporating both Piece 2 review points from #3210:

Maintainer review items addressed directly

  1. Explicit test-tsan exit-code check (Makefile.cbm): Uses if [ "$$rc1" -ne 0 ] || [ "$$rc2" -ne 0 ]; then exit 1; fi; instead of an AND list under set -e, so a failure in pipeline (rc1 != 0) can never come out green when the second group passes.
  2. Deterministic SIGALRM drain (tests/test_subprocess.c): Replaced the 2 ms sleep with a deterministic POSIX drain (sigprocmask(SIG_BLOCK) → setitimer disable → sigaction(SIG_IGN) → sigprocmask(SIG_UNBLOCK) / SIG_BLOCK → restore previous_action & mask) — zero sleeps, no timing dependence.

Harness & sharding changes

  • scripts/run-test-wave.py & scripts/run-tests-parallel.sh:
    • Deterministic LPT bin-packing across PAR, FLEX, and EXCL phases (with Shard 1 offset for Step 0/5 work).
    • Run per-suite-isolated tail suites in FLEX_FILE (CBM_TAIL_JOBS=2) while keeping extraction strictly exclusive (jobs=1).
    • Add --worker-cap (CBM_WORKERS=2 in PAR wave, exempting core-count-asserting suites system_info, platform, worker_pool, parallel) to prevent 4× oversubscription.
    • Fast Windows stamp_windows_build_dir (native whoami.exe /user SID + *.exe only instead of /T over thousands of objects).
  • scripts/test.sh & tests/test_{makefile_ts_runtime_dependencies,codeql_retrace,security_fuzz_harness}.sh:
    • Run Step 0 contracts and Step 5–6 prod-binary guards concurrently using temp log files (avoiding Windows pipe EOF hangs; CBM_CONTRACTS_SEQUENTIAL=1 fallback retained), skip redundant Step 0/5–6 on secondary shards (2/N..N/N) while Shard 1 runs every check, and parallelize slow internal contract loops.
  • scripts/msan.sh & scripts/ci/msan-lane.sh:
    • Run MSan suites in parallel via scripts/run-test-wave.py with FLEX/EXCL isolation (extraction and c_lsp exclusive to avoid 16 GiB swap thrashing), deterministic LPT sharding, shard-manifest emission, union guard, and content-verified ccache pass-through.
  • .github/workflows/_test.yml & scripts/ci/require-all-green.sh:
    • Shard test-diag, test-lsan-macos, and test-msan (2 shards each), right-size PR shard counts (N_X86=2, N_ARM=2, N_MAC=2, N_MAC_INTEL=2, N_WIN=4), schedule macos-15-intel first in CORE_UNIX to prevent runner-slot starvation, wire inputs.skip_perf to diag/lsan-macos/msan, upload shard manifests to shard-completeness, and map sharded job names in require-all-green.sh.
  • Makefile.cbm:
    • Consolidate 4 -dM -E compiler probes into one CC_DEFINES probe and make LLVM_BIN lazy (=) for faster make startup on Windows contract loops.

Local Verification (Apple M3, darwin/arm64)

  • test-tsan exit-code proof (synthetic runner, all 4 branches):
    • pipeline fail (rc1=1, rc2=0) → exited non-zero ✅
    • mem fail (rc1=0, rc2=1) → exited non-zero ✅
    • daemon fail → exited non-zero ✅
    • all pass → exited 0 ✅
  • tests/test_subprocess.c deterministic drain:
    • Compiled cleanly under -Wall -Wextra -Werror -fsanitize=thread (-fsyntax-only).
    • Standalone TSan loop of the exact sigprocmask + SIG_IGN drain passed 50 / 50 iterations with zero exit 142.
  • 4-shard LPT completeness proof:
    • scripts/run-tests-parallel.sh shards 1/4..4/4 verified by scripts/ci/verify-shard-union.sh: OK: ubuntu-latest-gcc — 4 shard(s), union of slices == full suite list.
  • Contracts: passed test_parallel_harness_contract.sh, test_harness_selection.sh, test_failure_report_contract.sh (63 checks), test_makefile_ts_runtime_dependencies.sh, test_codeql_retrace.sh, test_security_fuzz_harness.sh, test_lane_wiring_contract.sh, test_lane_gate_contract.sh, test_venue_parity_contract.sh, test_select_lanes.sh, check-no-test-skips.sh, check-dco.sh, bash -n / py_compile, and YAML validation on _test.yml.

Checklist

  • Every commit is signed off (git commit -s)
  • Local harness, sharding, TSan exit-code, SIGALRM drain, and contract proofs pass

…Step 0/5 & TSan

Split out from DeusData#3210 per maintainer review (Piece 2: test harness, sharding, wave runner, Step 0/5 parallelism, worker caps).

Addresses both Piece 2 review items from DeusData#3210:
- Makefile.cbm (test-tsan): use explicit `if [ "$$rc1" -ne 0 ] || [ "$$rc2" -ne 0 ]; then exit 1; fi;` instead of an AND list under `set -e` so a failing `pipeline` group can never exit 0 when the second group passes. Also consolidate 4 compiler `-dM -E` probes into one CC_DEFINES probe and make LLVM_BIN lazy.
- tests/test_subprocess.c: replace the 2 ms sleep with a deterministic POSIX SIGALRM drain (sigprocmask SIG_BLOCK -> setitimer disable -> sigaction SIG_IGN -> unblock/reblock -> restore) with zero sleeps or timing dependence.

Harness, sharding, and lane changes:
- scripts/run-test-wave.py & scripts/run-tests-parallel.sh: deterministic LPT bin-packing across PAR/FLEX/EXCL phases, FLEX tail jobs=2 (keeping extraction exclusive at jobs=1), PAR-wave --worker-cap 2 (exempting core-count-asserting suites), and fast Windows stamp_windows_build_dir.
- scripts/test.sh & tests/test_{makefile_ts_runtime_dependencies,codeql_retrace,security_fuzz_harness}.sh: parallel Step 0 contracts and Step 5-6 prod guards using temp log files (avoiding Windows pipe EOF hangs), skip redundant Step 0/5-6 on secondary shards while Shard 1 runs all contracts/guards, and parallelize slow Windows contract internals.
- scripts/msan.sh & scripts/ci/msan-lane.sh: run MSan suites in parallel via run-test-wave.py with FLEX/EXCL isolation, LPT sharding, shard-manifest emission, union guard, and content-verified ccache pass-through.
- .github/workflows/_test.yml & scripts/ci/require-all-green.sh: shard diag/lsan-macos/msan (2 shards each) and right-size PR shard counts with full shard-completeness union verification, wire inputs.skip_perf to diag/lsan-macos/msan, and schedule macos-15-intel first in CORE_UNIX.

Signed-off-by: Guillaume Demay <guillaumedemay@hotmail.fr>

This branch has not been deployed

No deployments
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.

1 participant