diff --git a/quest/m0/ci/README.md b/quest/m0/ci/README.md index 5a17251d99f..21294a618e3 100644 --- a/quest/m0/ci/README.md +++ b/quest/m0/ci/README.md @@ -92,7 +92,6 @@ The historical samples locate candidates; they are not controlled benchmarks. - [Share local check capacity](/quest/m0/ci/local-gate.md) - gate expensive phases and bound internal fanout - [Build queue entries concurrently](/quest/m0/ci/queue-concurrency.md) - the queue builds two or more entries at once instead of one - [Share Python check and test preparation](/quest/m0/ci/python-setup.md) - prepare editable bindings once per combined CI pass while preserving standalone commands -- [Parallelize OBS source checks](/quest/m0/ci/obs-parallel.md) - check independent translation units concurrently when OBS is on the critical path - [Measure nightly compiler levers](/quest/m0/ci/nightly-levers.md) - the parallel frontend and Cranelift, adopted only if the numbers beat their risks - [Bump to the manifest fix](/quest/m0/ci/mbx-bump.md) - condition: an mbx release contains jdx/mr-boxington#798; then bump the Rust cache's pin - [Verify the R2 Rust cache](/quest/m0/ci/mbx-r2-verify.md) - measure the hosted Nightly jobs' hits, restore time, and expiry once the bump lands diff --git a/quest/m0/ci/local-gate.md b/quest/m0/ci/local-gate.md index f16aba11b5d..8533a2d8884 100644 --- a/quest/m0/ci/local-gate.md +++ b/quest/m0/ci/local-gate.md @@ -16,7 +16,8 @@ also bounds its own worker fanout so it does not overwhelm the desktop. should remain cheap. Verify cancellation leaves no owned workload running. - Reuse mbx for Rust compilation. Measure nextest thread/group limits and Bun workspace fanout for local runs, and the module lanes `sh/dispatch.sh` - runs at once (`MOQ_CHECK_JOBS`); do not blindly enable mbx test scheduling + runs at once (`MOQ_CHECK_JOBS`, which also bounds the sources + `sh/obs/compile.sh` checks at once); do not blindly enable mbx test scheduling where queued time would consume nextest's timeout budget. - Benchmark representative solo and concurrent checkouts, recording wall time, CPU time, worker counts, cache state, and other host load. Compare total work diff --git a/quest/m0/ci/obs-parallel.md b/quest/m0/ci/obs-parallel.md deleted file mode 100644 index 25c441ae2d3..00000000000 --- a/quest/m0/ci/obs-parallel.md +++ /dev/null @@ -1,37 +0,0 @@ -# [S] Parallelize OBS source checks - -## Goal - -When OBS's syntax checks are on a queue entry's critical path after modules run -in parallel, they check independent translation units concurrently after -preparing their shared headers, without losing diagnostics or exceeding the -fanout bound modules share. Failure and cancellation leave no child checks -running. - -## Plan - -Decided 2026-10-23: module-level parallelism lands first, and this adds -translation-unit fanout inside `obs_compile` only where it still shortens the -entry. - -- `sh/obs/compile.sh` checks 20 source and test translation units sequentially. - The complete OBS compile module took 46 seconds in - [run 39996587979](https://github.com/moq-dev/moq/actions/runs/39996587979) - and 92 seconds in - [run 39993252909](https://github.com/moq-dev/moq/actions/runs/39993252909), - including header preparation, which these samples do not separate. -- Once modules overlap, measure whether `obs_compile` ends an entry, such as - one touching only `cpp/obs/`. If it never does, delete this quest. -- Finish `sh/obs/includes.sh` and its generated C++ package preparation before - starting concurrent syntax checks. Preserve all source/test coverage, - compiler flags, per-source diagnostics, and the aggregate failure result. -- Take concurrency from the module lane bound (`MOQ_CHECK_JOBS` in - `sh/dispatch.sh`) and local admission share; do not create a second - scheduling policy or unbounded fanout. -- Verify a failing source makes the command fail, all sources are checked, and - interruption reaps children. Compare serial and parallel runs on the same - inputs, reporting header preparation separately from compilation. - -## Related - -- [Share local check capacity](/quest/m0/ci/local-gate.md) - coordinate internal fanout with the shared local command budget diff --git a/sh/obs/compile.sh b/sh/obs/compile.sh index 577c49414b2..1da001fca25 100755 --- a/sh/obs/compile.sh +++ b/sh/obs/compile.sh @@ -38,6 +38,14 @@ for pkgs in "Qt6Widgets Qt6Gui Qt6Core" "libavcodec libavutil libswscale libswre fi done +# Sources check in parallel under the same bound as the module lanes +# sh/dispatch.sh runs at once, and with the same default. +limit=${MOQ_CHECK_JOBS:-3} +if [[ ! "$limit" =~ ^[1-9][0-9]*$ ]]; then + echo "error: MOQ_CHECK_JOBS must be a positive integer, not '$limit'" >&2 + exit 2 +fi + # Assign first so a failure in includes.sh still aborts under `set -e`, # then split on newlines only: an include path may contain spaces. includes_raw=$("$here/includes.sh") @@ -47,19 +55,56 @@ while IFS= read -r flag; do includes+=("$flag"); done <<<"$includes_raw" qt=$(pkg-config --cflags Qt6Widgets Qt6Gui Qt6Core) ffmpeg=$(pkg-config --cflags libavcodec libavutil libswscale libswresample) -# MOQ_VERSION_STRING only reaches a label in the dock, so any value -# type-checks the same; CMake stamps the real moq-cpp version. +logs=$(mktemp -d) +declare -A running=() +# Each check runs in its own process group, so a cancel reaches the compiler +# proper that the driver forks, not only the driver. +trap 'for pid in "${!running[@]}"; do kill -TERM -- "-$pid" 2>/dev/null || true; done; wait; rm -rf "$logs"' EXIT +trap 'exit 130' INT +trap 'exit 143' TERM + +# A failing source does not stop the rest, so one run reports every broken +# file. Each source's diagnostics print whole once it finishes, rather than +# interleaved with the checks beside it. +sources=(src/*.cpp test/*.cpp) +next=0 status=0 -for source in src/*.cpp test/*.cpp; do - # shellcheck disable=SC2086 - # -Werror: a warning that only prints is never fixed. - # -Wno-unused-command-line-argument: the nix compiler wrapper injects - # link flags, which a syntax-only run reports as unused, once per file. - # $qt and $ffmpeg stay unquoted on purpose: pkg-config hands back one - # space-separated string, and splitting it is the intended reading. - if ! "$cxx" -std=c++17 -fsyntax-only -Werror -Wno-unused-command-line-argument \ - "${includes[@]}" $qt $ffmpeg \ - -DMOQ_FRONTEND_ENABLED -DMOQ_VERSION_STRING='"0.0.0"' "$source"; then +while true; do + while ((next < ${#sources[@]} && ${#running[@]} < limit)); do + set -m + # shellcheck disable=SC2086 + # MOQ_VERSION_STRING only reaches a label in the dock, so any value + # type-checks the same; CMake stamps the real moq-cpp version. + # -Werror: a warning that only prints is never fixed. + # -Wno-unused-command-line-argument: the nix compiler wrapper injects + # link flags, which a syntax-only run reports as unused, once per file. + # $qt and $ffmpeg stay unquoted on purpose: pkg-config hands back one + # space-separated string, and splitting it is the intended reading. + # The job is a subshell around the compiler, so it exits even when the + # compiler is killed: bash 5.2 drops a job that a signal ends before + # `wait -n` collects it. The trailing exit keeps bash from exec'ing the + # compiler in the subshell's place. + ( + "$cxx" -std=c++17 -fsyntax-only -Werror -Wno-unused-command-line-argument \ + "${includes[@]}" $qt $ffmpeg \ + -DMOQ_FRONTEND_ENABLED -DMOQ_VERSION_STRING='"0.0.0"' "${sources[next]}" + exit + ) "$logs/$next" 2>&1 & + set +m + running[$!]=$next + next=$((next + 1)) + done + ((${#running[@]})) || break + + result=0 + wait -n -p pid "${!running[@]}" || result=$? + index=${running[$pid]} + unset "running[$pid]" + cat "$logs/$index" >&2 + # Named here because a compiler killed outright, such as by the OOM killer + # under concurrent checks, prints nothing that says which source it was. + if ((result)); then + echo "error: ${sources[index]} failed with status $result" >&2 status=1 fi done