Skip to content

perf(ci): parallelize and cache first-party builds, cppcheck, and language-count grep - #3210

Open
GDemay wants to merge 1 commit into
DeusData:mainfrom
GDemay:perf/ci-parallel-cached-builds
Open

GDemay wants to merge 1 commit into
DeusData:mainfrom
GDemay:perf/ci-parallel-cached-builds

Conversation

@GDemay

@GDemay GDemay commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

PR authored with AI assistance on behalf of @GDemay; all commits carry Guillaume's DCO sign-off.

Problem

Profiling recent PR CI runs (#3207 run 47552191451 at 82 min wall time; #3208 run 47561328853) showed four structural bottlenecks consuming the majority of build, lint, and pre-test wall time without adding any coverage:

  1. Single-core, uncacheable compilation of 267–474 first-party & test .c files (Makefile.cbm): test-runner, test-runner-tsan, test-repro-runner, codebase-memory-mcp, cbm-with-ui, cbm-fuzz, and test-runner-image-probe all pass every source file to a single $(CC) -o binary ... invocation. That serializes compilation onto 1 core even under make -j$(NPROC) and completely bypasses ccache (multi-file link commands are uncacheable).
  2. cppcheck runs with hardcoded CPPCHECK_JOBS ?= 2 and discards --cppcheck-build-dir (Makefile.cbm, scripts/lint.sh, _lint.yml): PR/lint / lint took ~14–16 min while leaving half of the 4-core runner idle and discarding .a1/.ctu-info state every PR push.
  3. Missing or unwired ccache across CI jobs (pr.yml, _test.yml, test-impact-artifact.yml):
    • pr-smoke lacked the cross-ref fallback restore key (ccache-smoke-${{ matrix.os }}-), causing cold misses on every new PR.
    • test-impact-shadow (report-only PR-checkout build) and test-impact-artifact (main-only) built without ccache.
    • test-diag and test-lsan-macos restored/saved .ccache without exporting CCACHE_DIR (test-diag also lacked /usr/lib/ccache/clang-21 symlinks, and test-lsan-macos invoked clang by absolute path, bypassing the ccache masquerade dir).
  4. Step 0w (tests/test_language_count_contract.sh) greps ~1.5 GB of generated parser.c tables: git grep -IlE scanned all 164 generated tree-sitter parser.c files on every test leg (~3m29s on test-windows).

Change

Scoped to the 7 files matching the PR title (+233 / -99 lines):

  • Makefile.cbm:
    • Compile first-party and test .c sources independently with -c -MMD -MP into flavour-isolated object directories ($(BUILD_DIR)/{t,i,s,p}/...) while preserving -O2 on the production link lines (codebase-memory-mcp, cbm-with-ui) and keeping $(PROJECT_HDRS) on binary link targets (repro_make_tracks_headers.sh).
    • Keep lsp_all.c as a single unity TU (prod_lsp_all.o, lsp_all.o, tsan_lsp_all.o), track its included .c/.h files via -MMD -MP, and drop the manual LSP_UNITY_DEPS list.
    • Include CC and CXX (plus STATIC / ZSTD_EXTRA_CFLAGS) in .build-config, .test-build-config, and .tsan-build-config across first-party and flavour-specific vendored objects so local builds cannot mix compilers or configs.
    • Leave cbm-third-party and CodeQL retrace rules intact.
    • Add optional CPPCHECK_BUILD_DIR support to lint-cppcheck (ephemeral mktemp -d remains the default when unset or empty).
  • scripts/lint.sh: Default CPPCHECK_JOBS=$NPROC unless overridden via argument or environment.
  • .github/workflows/_lint.yml: Cache ${{ github.workspace }}/.cppcheck-build strictly on github.event_name == 'pull_request', keyed on .cppcheck + Makefile.cbm. Release and dry-run gates never restore/save this cache and always run cppcheck in a fresh ephemeral temp dir.
  • .github/workflows/pr.yml, _test.yml, test-impact-artifact.yml:
    • Add the cross-ref ccache restore fallback and 1500M cap on pr-smoke.
    • Wire content-verified ccache into test-impact-shadow and test-impact-artifact.
    • Leave select-tests untouched to preserve its merge-base trust boundary.
    • Export CCACHE_DIR and CCACHE_MAXSIZE: 2500M on test-diag (with clang-21/clang++-21 ccache masquerade symlinks) and test-lsan-macos (via PATH masquerade), and raise CCACHE_MAXSIZE from 1500M to 2500M on test-unix, test-tsan, test-windows, and test-windows-guards.
  • tests/test_language_count_contract.sh: Exclude generated **/parser.c tables under internal/cbm/vendored/grammars/ and tools/ from the git grep scan.

Zero test coverage, sanitizer flags, compiler warnings, or security/venue/lane contracts are weakened or skipped.

Verification (Apple M3, 8 cores, darwin/arm64, CC=cc CXX=c++, CBM_NO_CCACHE=1)

  • Release binary parity (main 8633025a vs this branch 74cfd7e3, clean builds):
    • Byte-for-byte identical (cmp exit 0): SHA-256 0ebdcd7d30936e3be7e5a551ef2057287633a2d8cf5214d3922b48662899b8ea on both.
    • size -m identical across every segment/section (__text: 23,740,636, __const: 261,140,024, __cstring: 1,369,631).
    • nm -gU identical (all 5,159 exported symbols and addresses).
  • Incremental rebuild & config-stamp proofs:
    • Real no-op rebuild: 0 files recompiled.
    • Narrow header touch (-W src/cypher/cypher.h): 2 / 267 first-party .o files rebuilt (src/cypher/cypher.o, src/mcp/mcp.o).
    • prod_lsp_all.d: tracks 80 included .c/.h files automatically (including internal/cbm/lsp/rust_lsp.c, internal/cbm/cbm.h, and transitive src/foundation/arena.h).
    • Compiler switch (CC=cc → CC=clang): .build-config invalidates 439 / 439 compiled objects and removes the stale binary.
    • lint-cppcheck: verified ephemeral temp dir cleanup when CPPCHECK_BUILD_DIR is unset or empty (""), and persistence when set.
  • Contracts & dry-runs:
    • Passed: repro_make_tracks_headers.sh, test_makefile_ts_runtime_dependencies.sh, test_codeql_retrace.sh, test_language_count_contract.sh, test_lane_wiring_contract.sh, test_venue_parity_contract.sh, test_build_dir_safety.sh, test_windows_bundle_contract.sh, test_script_exec_bit_contract.sh, test_shell_line_endings.sh, check-no-test-skips.sh, check-dco.sh, scripts/sanitizer-coverage-map.py static, scripts/memwaste-padding.py command parsing (439 TUs), and make -n across all build targets (test-runner, test-repro-runner, test-runner-tsan, codebase-memory-mcp, cbm-fuzz, cbm-with-ui).

Checklist

  • Every commit is signed off (git commit -s)
  • Contracts and binary parity verified locally (CI running on 74cfd7e3)

@GDemay
GDemay requested a review from DeusData as a code owner December 5, 2026 20:39
@GDemay

GDemay commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

Comment authored with AI assistance on behalf of @GDemay.

All 37/37 checks passed on the full-matrix cold run (47566675666). Live GitHub Actions timings from this cold run vs the average of the previous 3 completed PR runs (#3209, #3208, #3207) and previous 2 full-matrix runs (#3206, #3200):

Job / Step Previous Avg PR #3210 (Cold 1st Run) Delta (Cold)
lint / lint (cppcheck -j4 + cached .cppcheck-build) 13m 50s 11m 54s -13.9% (warm cache saved in 2s)
test-unix (ubuntu-latest, x86) 38m 04s 24m 14s -36.3% (Step 5 cbm build: 54s)
test-unix (macos-15) 30m 44s 25m 11s -18.1%
test-windows (CLANG64) 59m 02s 51m 11s -13.3% (builds: 16m42s -> 7m35s cold)
test-tsan (ubuntu-latest) 14m 13s 8m 39s -39.2%
test-unix (ubuntu-24.04-arm, 1/2 & 2/2) (full-matrix avg) 22m 49s / 25m 06s 12m 57s / 14m 46s -43.2% / -41.2%
test-tsan (ubuntu-24.04-arm) (full-matrix avg) 13m 34s 8m 49s -35.0%
test-msan (full-matrix avg) 57m 58s 31m 14s -46.1%
test-lsan-macos (full-matrix avg) 46m 18s 41m 28s -10.4%
test-windows-guards (full-matrix avg) 10m 10s 8m 05s -20.4%
Step 0w (test_language_count_contract.sh) — Ubuntu / Windows 16.3s / 3m 29s 0.53s / 14.3s -96.7% / -93.1%

Because this run was the first run with the new per-object rules and .cppcheck-build key, all ~740 newly cacheable first-party + test .o compilations (Cacheable calls rose from 7,980 to 9,129 on Windows) and .cppcheck-build were cold misses that are now populated for warm-cache hits on subsequent runs.

@GDemay

GDemay commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

@DeusData hi, I think improving the speed of the ci cd would be a good benefit.

I am running some optimization with Gemini neon .

What do you think ? There is a lot of modification in the code so we need to carefully review it but from what I reviewed, there were no regressions at all.

@GDemay

GDemay commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

Comment authored with AI assistance on behalf of @GDemay; all commits carry Guillaume's DCO sign-off.

All 49/49 checks (including dco, shard-completeness across every sharded leg, test-tsan on x86/arm/macOS, test-msan, test-lsan-macos, test-diag, test-windows x6, codeql, pr-smoke, and ci-ok) passed green on run 47597038729 (b26eb269) with zero skipped tests, zero dropped platforms/sanitizers, and zero production (src/ / internal/) changes.

Measured Live GitHub Actions Timings: Baseline vs PR #3210 (Warm Cache, Run 47597038729)

Baseline = average of the previous 3 PR runs before #3210 (#3209 69m 23s, #3208 74m 49s, #3207 81m 46s — avg 75m 19s), plus average of the previous 2 full-matrix runs (#3206 68m 16s, #3200 91m 52s — avg 80m 04s) for legs not selected on smaller PRs:

Leg / Stage Baseline Avg PR #3210 Final (47597038729) Speedup
changes (sparse-checkout) 0m 46s 0m 07s 6.6× (-85%)
lint / lint (cppcheck -j + cached .cppcheck-build) 13m 50s 1m 21s 10.2× (-90%)
lint / lint-mem 1m 35s 0m 37s 2.6× (-61%)
test-msan (2 shards, parallel + c_lsp_b isolated) 57m 58s 8m 09s / 7m 44s 7.1× (-86%)
test-diag (2 shards, clang-21 ccache fixed) 56m 12s 11m 46s / 7m 20s (Iter 6: 9m 14s / 8m 40s) 4.8×–6.1× (-79% to -84%)
test-unix (ubuntu-latest, x86) (3 shards) 38m 04s 7m 16s / 4m 49s / 5m 28s 5.2× (-81%)
test-windows (CLANG64) (6 shards) 59m 02s 4m 44s – 13m 39s (Iter 7: 6m 43s – 11m 35s) 4.3×–5.1× (-77% to -80%)
test-lsan-macos (2 shards) 46m 18s 12m 08s / 11m 35s 3.8× (-74%)
test-unix (macos-15) (2 shards) 30m 44s 11m 38s / 8m 40s 2.6× (-62%)
test-unix (macos-15-intel) (2 shards) 54m 06s 15m 59s / 19m 19s (Iter 6: 14m 31s / 14m 30s) 2.8×–3.7× (-64% to -73%)
test-unix (ubuntu-24.04-arm) (2 shards) 25m 06s 9m 32s / 6m 06s 2.6× (-62%)
test-tsan (x86 / arm / mac) 14m 13s / 13m 34s / 13m 18s 4m 41s / 6m 19s / 9m 58s 3.0× / 2.1× / 1.3×
pr-smoke (ubuntu / mac / win) 13m 36s / 13m 30s / 18m 00s 4m 57s / 5m 47s / 9m 37s 2.7× / 2.3× / 1.9×
codeql / analyze (c-cpp) (cached untraced vendored prebuild) 20m 39s 14m 53s 1.4× (-28%)
memwaste / event-linux / scaling-linux (cached builds) 7m 42s / 25m 32s 3m 41s / 15m 31s 2.1× / 1.65×
shard-completeness + ci-ok (sparse-checkout) 0m 45s + 0m 40s 0m 13s + 0m 13s 3.3× (-69%)

End-to-End PR Impact

  • Typical C PR (T1/T2/T3 — ~95% of PRs, 16 jobs, zero runner-cap contention): drops from 75m 19s avg to ~13–15 min un-narrowed (100% of all C suites across x86, macOS, and Windows — ~5–6× faster / -80% to -83%), and ~5–7 min once select-tests narrows to impacted suites (also post-merge select-tests drops from ~3m to ~1m once main picks up per-object builds).
  • Full 51-job matrix (workflow / Makefile.cbm PRs, uncontended): drops from 80m 04s avg to ~23–25 min (~3.3× faster / -70%), bounded by GitHub's 5-concurrent-macOS-runner limit across the 8 macOS legs.

Key Changes Summary

  1. Per-object -c -MMD -MP builds + lsp_all.c split (30 TUs) in Makefile.cbm: enables ccache across ~740 first-party, test, and LSP objects (95–98% cacheable; warm full builds drop to ~15–25s), plus fixed missing /usr/lib/ccache/clang-21 symlinks in test-diag, untraced vendored caching in codeql.yml, and ccache in _memwaste.yml.
  2. Parallelized cppcheck -j$(nproc) + cached .cppcheck-build in _lint.yml / scripts/lint.sh (13m 50s -> 1m 21s).
  3. Parallelized Step 0 contracts (46 scripts), Step 5–6 prod guards (8 scripts, using temp log files to avoid Windows pipe-EOF hangs), test_codeql_retrace.sh, test_makefile_ts_runtime_dependencies.sh, and test_security_fuzz_harness.sh, plus excluded vendored parser.c in Step 0w and fixed the 300s smoke-test.sh Phase 15 stdin-holder hang.
  4. Deterministic LPT sharding + secondary-shard deduplication + shard-completeness proof across test-unix, test-windows (6 shards), test-diag (2 shards), test-lsan-macos (2 shards), and test-msan (2 shards, with c_lsp_b isolated in TAIL_EXCL to eliminate swap thrashing under 4× MSan shadow RAM).
  5. Long-tail suite splits (zero coverage/assertion changes) in tests/ (cli/cli_b, pipeline/pipeline_b/pipeline_c/pipeline_d, doc_mentions/doc_mentions_e/doc_mentions_b/doc_mentions_d, c_lsp/c_lsp_b, test_impact_git/test_impact_git_b/test_impact_git_c, stack_overflow_a/b/c, complexity/complexity_b, grammar_probe_f/grammar_probe_f_b, java_type_scope/java_type_scope_b, pipeline_semantic_manifest_repro/_b) + 2-phase TSan isolation in Makefile.cbm.
  6. DAG critical-path trimming: sparse-checkout on changes, shard-completeness, and ci-ok (40s -> 7–13s), and starting select-tests at T=0 in parallel with changes.

@GDemay

GDemay commented Dec 6, 2026

Copy link
Copy Markdown
Contributor Author

Final warm-cache CI results (commit ae770ac4, Run 47613975077 — dco, shard-completeness, and ci-ok all GREEN, 0 src//internal/ edits)

Iterations 9–10 added:

  • Compiler / linker / sanitizer optimizations (Makefile.cbm, Dockerfile.msan, cache-warm.yml): DEBUG_INFO ?= -g1 (shrinking .ccache archives to 0.2–0.5 GiB), TEST_OPT ?= -O2 / TEST_SUITE_OPT ?= -O1, auto-probed -fuse-ld=lld on Linux test/TSan/MSan links, and dead ASan UAR prologue suppression on non-diag vendored test objects only (test-diag and all first-party code untouched).
  • Test-fixture copy/hash/spawn elimination (tests/): replaced 500–800 MB test-runner self-copies with the 1.9 MB test-runner-image-probe helper, armed the existing fingerprint hash stub for same-binary lifecycle tests (keeping real hash tests intact), template-cached base repos in test_test_impact_git.c, added a 10s TSParseOptions.progress_callback cap on Windows so_parse_crashes, split pure in-process mcp from mcp_supervisor, and fixed a pre-existing macOS TSan SIGALRM drain race in tests/test_subprocess.c.
  • Harness, Windows ACL, smoke, and workflow speedups (scripts/, .github/workflows/): native whoami.exe + *.exe-only Windows build-dir ACL stamping (~0.22s vs 20–40s), per-suite-isolated FLEX tail (jobs=2) + --worker-cap 2 on PAR waves + calibrated LPT weights, warm daemon + CoW copies + parallel wrappers + early-exit Phase 15 in smoke tests, merge-base select-tests binary caching, blobless sparse checkouts on lint/UI/wrappers/CodeQL, and Homebrew bottle caching on macOS.

Measured per-job execution times (warm cache, Run 47613975077 vs recent main PR baselines)

Job / Leg Baseline (#3209/#3208/#3207 avg, or #3206/#3200 full-matrix avg) PR #3210 (ae770ac4, warm) Speedup
changes 0m 44s 0m 05s 8.8×
lint / lint 13m 50s 0m 59s (0m 33s on prior run) 14.1×
lint / lint-mem 1m 22s 0m 57s 1.4×
select-tests 5m 16s 0m 47s 6.7×
pr-smoke (ubuntu) 13m 57s 3m 37s 3.9×
pr-smoke (macos) 13m 50s 5m 28s 2.5×
pr-smoke (windows) 15m 34s 7m 02s 2.2×
test-unix (ubuntu-latest x86) 38m 04s 7m 06s (1/2) / 5m 54s (2/2) 5.4×
test-unix (ubuntu-24.04-arm) 25m 06s 7m 04s (1/2) / 4m 49s (2/2) 3.6×
test-unix (macos-15) 30m 44s 9m 02s (1/2) / 8m 48s (2/2) 3.4×
test-unix (macos-15-intel) 48m 33s 14m 36s (1/2) / 10m 17s (2/2) 3.3×
test-windows (4 shards) 59m 02s 14m 18s / 11m 10s / 9m 54s / 8m 57s 4.1× (5.4× on Run 47611644168: max 10m 58s)
test-diag (2 shards) 51m 17s 8m 21s (1/2) / 6m 33s (2/2) 6.1×
test-msan (2 shards) 57m 58s 5m 36s (1/2) / 5m 48s (2/2) 10.0×
test-lsan-macos (2 shards) 46m 18s 10m 25s (1/2) / 9m 53s (2/2) 4.4×
test-tsan (x86 / arm / mac) 14m 13s / 13m 34s / 15m 56s 5m 49s / 5m 38s / 8m 59s 1.8×–2.4×
test-ui / test-package-wrappers 2m 40s / 1m 53s 2m 32s / 0m 43s (Linux), 1m 25s (Win) 1.1×–1.5×
shard-completeness + ci-ok 1m 22s 0m 07s + 0m 06s 6.3×
  • End-to-end wall time (created -> ci-ok):
    • Full-matrix PR (all 44 active jobs, workflow-touching PR): 80m 03s avg (#3206 68m 15s, #3200 91m 51s) → 39m 15s (2.0× faster, −51%), bounded by GitHub's 3-concurrent-macOS-runner limit across 8 macOS jobs (macos-15-intel 1/2 queued 21m 32s).
    • Typical C PR (16-lane scope like #3209/#3208/#3207, zero macOS/Windows runner queuing): 75m 18s avg → ~12–16m to ci-ok (~4.6×–5.8× faster, −78% to −83%; all C test legs complete in 6–14m, with parallel codeql-cpp at 16m 26s).

Every contract, sanitizer, platform, test case, and security gate remains 100% intact. Ready for review.

Comment authored with AI assistance on behalf of @GDemay; all commits carry Guillaume's DCO sign-off.

@DeusData

DeusData commented Dec 6, 2026

Copy link
Copy Markdown
Owner

Thank you, @GDemay, there's a lot of careful engineering in here, and per-object builds with real dependency tracking would fix a stale-incremental-build trap we've hit ourselves. We reviewed it in full and compared the release binary, so here is everything at once.

One blocker: a failing TSan run can come out green

In Makefile.cbm's parallel test-tsan recipe, the last line of the if branch is

[ "$$rc1" -eq 0 ] && [ "$$rc2" -eq 0 ];

Under set -e, a failure in any command of an AND list other than the last is not fatal. So when the pipeline group fails (rc1 != 0), the recipe carries on, and if the daemon group then passes, it exits 0. We reproduced it in sh and bash: rc1=1 gives exit 0, and rc2=1 gives exit 1. Every CI and release TSan leg reaches this through scripts/test.sh, so a real race in pipeline would be reported green. Please make it explicit, e.g. if [ "$$rc1" -ne 0 ] || [ "$$rc2" -ne 0 ]; then exit 1; fi.

What we measured on the release binary (macOS arm64, main vs main + this branch, clean builds)

  • Compile flags of the shipped objects are identical (-O2 and the rest).
  • Exported symbols are identical (5,159), and __const/__cstring are identical.
  • It is not byte-identical: __text shrinks from 23.74 MB to 22.67 MB. That's because the LSP unity file (lsp_all.c) is split into 30 TUs for the shipped binary too, and the scanner statics become separate copies, so inlining and layout change.
  • Behaviour is identical: the graphs of five repositories in five languages (celery, cargo, nest, eladmin, leveldb, about 288,000 edges and their nodes) match exactly.

Scope: please split it

The title covers per-object builds, ccache/cppcheck caching and the language-count grep. The branch now also reworks test sharding and the wave runner, the MSan lane (sequential to sharded), diag/lsan sharding and require-all-green.sh, Step 0/5 parallelism and secondary-shard skips in scripts/test.sh, sanitizer test flags (-g -O1 to -g1 -O2, ASan use-after-return off for vendored code, lld), the CodeQL wait, smoke-test daemon warming, the select-tests engine cache, 14 new suite splits, and self-image hash stubs. Several of these change gates, so each needs its own review and a maintainer decision. Could you split it roughly like this?

  1. Per-object Makefile.cbm with -MMD -MP plus the lint/cppcheck/grep work (the title). For the shipped binary, please either keep lsp_all.c as one TU, or add a contract that checks the 30-file list against lsp_all.c plus -Werror=implicit-function-declaration. And drop the now-dead LSP_UNITY_DEPS.
  2. Test harness: sharding, the wave runner, Step 0/5 parallelism, worker caps.
  3. Sanitizer-flag changes (-O2/-g1/UAR-off), as an explicit decision with a reason.
  4. Suite splits and the hash stubs.
  5. CI-only items: the CodeQL wait, smoke warming, the select-tests cache.

Points for the respective pieces

  • select-tests trust: the selection engine now comes from a cache keyed by the base SHA, or a ccache-backed build. pr.yml itself says the engine must come from the base, never from the PR, and a restore checks the PR's own cache scope first. Please take it from main's test-impact artifact, or verify its SHA-256 against it, and don't use ccache in that job.
  • cppcheck results cache: release and dry-run gates call _lint, so they would restore it too. Please restore it only on pull_request.
  • CodeQL: the alert wait drops from 60+15 s to 5+5 s. Please keep it unless a measurement shows the longer wait is unnecessary.
  • tests/test_subprocess.c: the new 2 ms sleep makes a pass depend on timing, and this project doesn't allow that. A deterministic drain (e.g. on SIGALRM) would keep the test exact.
  • Config stamps: please include CC/CXX, so a local build can't mix compilers.

Security-wise nothing stood out: actions are pinned, there's no pull_request_target, no permission changes and no new secrets. The test-tsan masking and the select-tests trust point are the ones that matter most. Thanks again for the effort here; the first piece on its own would already be a nice win.

…guage-count grep

- Makefile.cbm: compile first-party and test .c TUs independently with -c -MMD -MP into flavour-isolated object directories (t/, i/, s/, p/) while preserving -O2 on production link lines, keeping lsp_all.c as a single unity TU tracked via -MMD -MP (dropping manual LSP_UNITY_DEPS), including CC/CXX/STATIC in config stamps across first-party and vendored objects, keeping PROJECT_HDRS on binary link targets, and adding optional CPPCHECK_BUILD_DIR support to lint-cppcheck.
- scripts/lint.sh: default CPPCHECK_JOBS to detected NPROC unless overridden.
- .github/workflows/_lint.yml: cache .cppcheck-build strictly on pull_request (release and dry-run gates continue using a fresh ephemeral temp dir).
- .github/workflows/pr.yml, _test.yml, test-impact-artifact.yml: add cross-ref ccache fallback on pr-smoke, wire content-verified ccache into test-impact-shadow and test-impact-artifact, export CCACHE_DIR and clang-21/Homebrew PATH masquerade on test-diag and test-lsan-macos, and raise test-leg CCACHE_MAXSIZE to 2500M. Leave select-tests untouched to preserve its merge-base trust boundary.
- tests/test_language_count_contract.sh: exclude generated tree-sitter parser.c tables from git grep.

Signed-off-by: Guillaume Demay <guillaumedemay@hotmail.fr>
@GDemay
GDemay force-pushed the perf/ci-parallel-cached-builds branch from ae770ac to 74cfd7e Compare December 6, 2026 18:19
@GDemay

GDemay commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor Author

Comment authored with AI assistance on behalf of @GDemay; all commits carry Guillaume's DCO sign-off.

Thank you for the thorough review and the release-binary comparison, @DeusData — really appreciate the clear breakdown and especially catching the test-tsan exit-code masking bug.

Split index (all standalone on main 8633025a)

  1. Piece 1 — #3210 (this PR, 74cfd7e3): Per-object Makefile.cbm with -MMD -MP, cppcheck parallelism/PR-only cache, safe ccache wiring, and parser.c grep exclusion (7 files, +233 / -99).
  2. Piece 2 — perf(ci): shard sanitizer legs, LPT-pack test waves, and parallelize Step 0/5 & TSan #3220 (1f94a2d5): Test harness, sharding, wave runner, Step 0/5 parallelism, worker caps — with the explicit test-tsan exit-code check (if [ "$$rc1" -ne 0 ] || [ "$$rc2" -ne 0 ]; then exit 1; fi) and deterministic POSIX SIGALRM drain in tests/test_subprocess.c (zero sleeps).
  3. Piece 3 — queued on #3210: Sanitizer-flag changes (-O2/-g1/vendored UAR-off/lld). Held until #3210 lands because separating TEST_OPT=-O2 (src/ + vendored) from TEST_SUITE_OPT=-O1 (tests/*.c) builds on #3210's per-object pattern rules.
  4. Piece 4 — perf(tests): split long-tail suites, reuse image probe, and stub self-image hashes #3219 (58d367c2): 14 suite splits, test-runner-image-probe reuse, and runtime fingerprint hash stubs (zero workflow changes; 3,001 RUN_TEST multiset parity verified, 2,896 passed / 0 failed locally).
  5. Piece 5 — perf(ci): speed up smoke runs, sparse checkouts, and verified select-tests artifact #3221 (7c0ac7f2): CI-only items (smoke warming + Phase 15 hang fix, sparse checkouts, cache-warm/_memwaste) — with select-tests fetching a provenance- and SHA-256-verified test-impact-engine-<sha> artifact from main's test-impact-artifact.yml (no PR cache, CBM_NO_CCACHE=1 fallback) and CodeQL's sleep 60 + sleep 15 alert wait left untouched.

Details addressed in Piece 1 (#3210, 74cfd7e3)

  1. Shipped binary & lsp_all.c (LSP_UNITY_DEPS dropped):
    • Kept lsp_all.c as a single unity TU (prod_lsp_all.o, lsp_all.o, tsan_lsp_all.o), switched it to -MMD -MP (prod_lsp_all.d tracks all 80 included .c/.h files including transitive src/ headers), and removed the now-dead LSP_UNITY_DEPS.
    • Also preserved -O2 on the production link lines (codebase-memory-mcp, cbm-with-ui) so Apple ld keeps -O2 link-time deduplication (without -O2 on the link line, __text grew by ~71 KB on macOS).
    • Verified locally on macOS arm64 (CC=cc CXX=c++, CBM_NO_CCACHE=1, clean main 8633025a vs clean 74cfd7e3): the shipped release binary is byte-for-byte identical (cmp exit 0, SHA-256 0ebdcd7d30936e3be7e5a551ef2057287633a2d8cf5214d3922b48662899b8ea, identical size -m with __text = 23,740,636, identical nm -gU across all 5,159 exported symbols and addresses).
  2. Config stamps include CC/CXX:
    • Added CC=$(CC)|CXX=$(CXX) to .build-config (alongside STATIC), .test-build-config (alongside ZSTD_EXTRA_CFLAGS), and .tsan-build-config, and wired the stamps onto both first-party and flavour-specific vendored objects (including prod_mimalloc.o).
    • Verified locally that switching CC=cc → CC=clang invalidates 439 / 439 compiled objects and removes the stale binary so local builds cannot mix compilers.
  3. cppcheck cache restricted to pull_request (_lint.yml):
    • Gated both the actions/cache step and CPPCHECK_BUILD_DIR strictly on github.event_name == 'pull_request'. Release and dry-run calls to _lint.yml leave CPPCHECK_BUILD_DIR empty and run cppcheck in a fresh ephemeral mktemp -d (verified locally for unset and empty CPPCHECK_BUILD_DIR="").
  4. select-tests trust (pr.yml):
  5. Contracts verified locally:
    • Passed repro_make_tracks_headers.sh, test_makefile_ts_runtime_dependencies.sh, test_codeql_retrace.sh, test_language_count_contract.sh, test_lane_wiring_contract.sh, test_venue_parity_contract.sh, test_build_dir_safety.sh, test_windows_bundle_contract.sh, test_script_exec_bit_contract.sh, test_shell_line_endings.sh, check-no-test-skips.sh, check-dco.sh, sanitizer-coverage-map.py static, and memwaste-padding.py dry-run parsing.

GDemay added a commit to GDemay/codebase-memory-mcp that referenced this pull request Dec 6, 2026
…tests artifact

Split out from DeusData#3210 per maintainer review (Piece 5: CI-only items).

Addresses both Piece 5 review items from DeusData#3210:
- select-tests trust (scripts/ci/test-impact-bundle.sh, test-impact-artifact.yml, pr.yml): publish the main-built selection engine binary + SHA-256 receipt (engine.json) as artifact test-impact-engine-<sha> from test-impact-artifact.yml on main, and fetch/verify it in select-tests via test-impact-bundle.sh --fetch-engine using the same main-branch workflow-run provenance check as test-impact-<sha>. No actions/cache, no PR cache scope, and CBM_NO_CCACHE=1 on the clean base-tooling fallback build.
- CodeQL alert wait (.github/workflows/codeql.yml): keep sleep 60 + sleep 15 completely untouched. Keep only blobless sparse checkouts, upload-database: !inputs.light, wait-for-processing: true, and ccache strictly scoped to the untraced --vendored-only prebuild (traced CodeQL build keeps CBM_NO_CCACHE=1).

Smoke & CI provisioning speedups:
- scripts/smoke-test.sh, smoke-local.sh, smoke-wrappers.sh: fix Phase 15 300 s hang on non-UI PR smoke builds (track/kill stdin-holder sleep PID + 30 s wall-clock deadline + bounded curl timeouts + stderr early-exit), keep daemon warm across Phases 3b-5, use CoW binary copies, drop dead retired-install copy, use COPYFILE_DISABLE=1 GZIP=-1 for local tarball, and run wrapper suites in parallel.
- .github/workflows/_lint.yml, _memwaste.yml, _test.yml, cache-warm.yml: add blobless sparse checkouts skipping unused vendored grammars/tools/graph-ui, merge duplicate apt-get updates, add npm cache + IPv4 DNS order on test-ui, add Homebrew bottle cache / HOMEBREW_NO_AUTO_UPDATE=1 on macOS legs, wire ccache into report-only _memwaste.yml, and warm cbm TEST_SEAMS=1 (2500M) in cache-warm.yml.

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.

2 participants