docker: the test stage's parallelism and CPU budgets apart from the compile (build.sh -J, -B)

The per-binary CPU budgets are set on a fast machine. A VM on an EPYC 7302 spends 4.6x the quoted
CPU time on tokenizer_test's reference pass, so the image's test stage failed there on a correct
tree, and -j sized for the compile also sized the tests: twelve at once on a 24-thread host put
tests on busy SMT siblings, which costs CPU seconds too.

RAD_TEST_CPU_BUDGET_SCALE multiplies the budget where rad_test.h reads it, at run time, so a
direct ctest takes it as well and the build layer is untouched by it. The stage takes it as
TEST_CPU_BUDGET_SCALE (build.sh -B) and its parallelism as TEST_JOBS (build.sh -J), each empty by
default, which is the stage as before. harness_test checks the factor and keeps it out of its
fixture's environment; docs/DOCKER.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
NunzeandClaude Opus 5.5 committed 2026-10-19 13:37:01 +02:00
1 parent 44aecb0ab8
commit 748f63637e
5 files changed
+33 -6

No files matched your search

+11 -4
View File
@@ -202,21 +202,28 @@ RUN echo 1000 > /proc/self/oom_score_adj 2>/dev/null || true; \
# ------------------------------------------------------------------------------------------- test
FROM build AS test
ARG JOBS=
# Tests at a time when it should differ from JOBS (below).
ARG TEST_JOBS=
# A factor on every test's CPU budget (RAD_TEST_CPU_BUDGET_SCALE, tests/rad_test.h), for a host
# slower per thread than the one the budgets were set on: a VM on an EPYC 7302 spends 4.6x the
# quoted CPU time on tokenizer_test's reference pass.
ARG TEST_CPU_BUDGET_SCALE=
# Host-only: a build container has no /dev/kfd. The `gpu`-labelled tests (the *_card entries,
# r4d_selftest, kbench) run against a card from this stage:
# docker buildx build --target build -t radiance-build . && docker run --rm \
# --device /dev/kfd --device /dev/dri --security-opt seccomp=unconfined radiance-build \
# ctest --test-dir /build -L gpu --output-on-failure
# Tests run JOBS at a time (default one per two hardware threads, about one per core on an SMT
# machine: the per-binary CPU budgets in tests/CMakeLists.txt hold for tests that do not share a
# core); the `perf` entries, which assert wall-clock costs, run alone (RUN_SERIAL). The build
# Tests run TEST_JOBS at a time, else JOBS (default one per two hardware threads, about one per
# core on an SMT machine: the per-binary CPU budgets in tests/CMakeLists.txt hold for tests that do
# not share a core); the `perf` entries, which assert wall-clock costs, run alone (RUN_SERIAL). The build
# sandbox forbids io_uring, so avx_check skips its file-backed gather case, and perf_event_open, so
# the tests that bound work count CPU time rather than instructions (tests/work_counter.h). The
# `oot` suite (every shipped plugin rebuilt against the installed package) repeats this stage's
# whole compile, so it runs from the development tree instead (tests/oot_plugins.sh).
RUN echo 1000 > /proc/self/oom_score_adj 2>/dev/null || true; \
bash /src/docker/llvm-check.sh /build \
&& ctest --test-dir /build -LE 'gpu|oot' -j"${JOBS:-$(( ($(nproc) + 1) / 2 ))}" --output-on-failure \
&& RAD_TEST_CPU_BUDGET_SCALE="${TEST_CPU_BUDGET_SCALE}" \
ctest --test-dir /build -LE 'gpu|oot' -j"${TEST_JOBS:-${JOBS:-$(( ($(nproc) + 1) / 2 ))}}" --output-on-failure \
&& touch /build/host-tests-passed
# ----------------------------------------------------------------------------------------- rootfs