Skip to content

ci: run ctest with -j 4, so the 14.5 min Test step stops being one binary at a time - #2826

Merged
bong-water-water-bong merged 4 commits into
mainfrom
cl-infra/ci-ctest-j4
Nov 17, 2026
Merged

bong-water-water-bong merged 4 commits into
mainfrom
cl-infra/ci-ctest-j4

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Cherry-picked from ORCH's CI-time task (owner asked for the lever). One line of behaviour change: the Test step runs ctest -j 4. Everything else — the build/ctest.log redirect, set +e / exit $rc, the log the next step reads — is untouched.

Where the time is

Measured on main run 43998969466 (job build, 23m total): Build 7.28m, Test 14.55m. The Test step ran ctest --test-dir build --output-on-failure --timeout 600 serially on a 4-vCPU ubuntu-24.04 runner, i.e. roughly two thirds of main CI was one test binary at a time.

What cannot run concurrently, checked rather than assumed

hazard finding
fixed ports Every configured test that starts a server already holds RESOURCE_LOCK route_ports (CMakeLists.txt: the engine#1070 list under the registration glob, plus http_guard, hw_gate_npuserve, and the conditional serve_client_hangup_cpu / serve_context_limit_cpu). The census row route_port_lock fails when a new server test is added without the lock, so this cannot drift — and ctest honours RESOURCE_LOCK under -j, so those serialise against each other and nothing else does.
shared filesystem paths Nothing in tests/ writes a fixed path — every test that writes uses mktemp -d (hw_gate_mem, hw_gate_zero_cases, hybrid_route, npu_import_contract, hrx_cpu_weight_parity, registration_glob, copyright_gate, gpu_hold_*). The 45 fixed /tmp sites in tools/ci/tmp_paths.txt are product code under app/ and npu/, reached only by device rows that skip here (tmp_path_check: 44 baselined, none new).
NPU/GPU device No row in this CI build binds the device: npu_device_lock is device-free by design (a forked flock on a temp file), and the device/model rows need a model and return 77.
build-tool invoking tests registration_glob, copyright_gate and the gate/route scripts each build into their own mktemp -d; none rebuilds the shared build/ tree. route_port_lock's own ctest -N --show-only=json-v1 only reads CTestTestfile.cmake.

No row needed a new lock or an exclusion, so nothing was serialised beyond what the port lock already covers.

The parser the next step depends on keeps working

tools/ci/ctest_skips.py reads two shapes out of build/ctest.log. A 4-test probe project run with -j 4 prints the same two:

2/4 Test #2: t_skip ...........................***Skipped   0.00 sec
100% tests passed, 0 tests failed out of 4

and running ctest_skips.py on the -j 4 log and on the serial log of the same project yields the identical set of findings — including the unbaselined-skip failure (ctest_skips: t_skip SKIPPED and the baseline does not name it …, rc 1). So a new skip is still caught when tests run in parallel.

The measurement this PR exists for

This PR's own build is the experiment: old 23m total (Build 7.28m / Test 14.55m) against the new total and Test time, reported here when it finishes. If any test fails only under -j 4, I will say which one and fall back to -j 2 rather than weakening a test.

…nary at a time

Measured on main run 43998969466 (job build, 23m total): Build 7.28m, Test 14.55m.
The Test step ran ctest serially on a 4-vCPU runner. One flag; the log redirect,
the set +e / exit $rc handling and the build/ctest.log the next step reads are
untouched.

What in the suite cannot run concurrently, and why -j 4 is safe anyway:

  * FIXED PORTS. Every configured test that starts a server already holds
    RESOURCE_LOCK route_ports (CMakeLists.txt: the engine#1070 list below the
    registration glob, plus http_guard, hw_gate_npuserve and the conditional
    serve_client_hangup_cpu/serve_context_limit_cpu rows). The census row
    route_port_lock fails when a new server test is added without the lock, so
    this cannot drift. ctest honours RESOURCE_LOCK under -j: those tests
    serialise against each other and nothing else does.
  * SHARED FILESYSTEM PATHS. Nothing in tests/ writes a fixed path: every test
    that writes uses mktemp -d (checked hw_gate_mem, hw_gate_zero_cases,
    hybrid_route, npu_import_contract, hrx_cpu_weight_parity, registration_glob,
    copyright_gate, gpu_hold_*). The 45 fixed /tmp sites in
    tools/ci/tmp_paths.txt are product code under app/ and npu/, reached only by
    device rows that skip in this configuration (tmp_path_check: 44 baselined,
    none new).
  * NPU/GPU DEVICE. No row in this CI build binds the device: npu_device_lock is
    device-free by design (a forked flock on a temp file), and the device/model
    rows need a model and return 77 here.

Proof that the log stays readable: a 4-test probe project under -j 4 prints the
same two shapes ctest_skips.py parses ('2/4 Test #2: t_skip ...***Skipped' and
'100% tests passed, 0 tests failed out of 4'), and running ctest_skips.py on the
-j 4 log and on the serial log of the same project yields the identical set of
findings (including the unbaselined-skip failure, rc 1).

The engine to measure it is this PR's own build.

Refs ORCH 2026-11-17 (CI-time lever).
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit e94c569)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Regex Coverage for Shell Port Definitions

The updated regex BIND_RE in route_port_lock_test.py now includes a pattern to detect shell variable assignments with fixed port defaults like PORT=${EMBED_SERVE_PORT:-8247}. While this improves detection of fixed ports, the test cases added to verify this behavior (test_the_census_finds_the_route_tests) only cover a specific instance and do not comprehensively validate that all possible shell port default patterns are correctly identified. This could lead to missed fixed ports in future test additions or modifications.

for name in ("pm_route", "print_backend", "smoke_serve", "embed_serve"):
    self.assertIn(name, found, f"{name} starts a server; the census must find it")
# engine#2826: a port written as a shell default -- `PORT=${EMBED_SERVE_PORT:-8247}` -- matched none of the
# three shapes above, so a fixed-port server test sat unlocked while this census reported OK (embed_serve,
# until its port became a freeport). This pins the SHAPE rather than that one script: the next row that writes
# a fixed default is caught here instead of by a flake.
self.assertTrue(BIND_RE.search("PORT=${EMBED_SERVE_PORT:-8247}"),
                "a shell-default fixed port is a fixed port; the census must recognise the shape")
self.assertFalse(BIND_RE.search("PORT=${X:-80}"),
                 "...but a two-digit default is not one (keeps the pattern from matching every shell var)")
# 5 in a build with no model passed; a model-enabled build configures more (hybrid_e2e,
Temporary File Handling for Parallel Execution

The embed_serve.sh script was updated to use mktemp for temporary files (ER1, ER2) to prevent conflicts during parallel execution. However, the cleanup logic still uses hardcoded paths (/tmp/embed_serve_er1, /tmp/embed_serve_er2) in the rm -f command, which could cause issues if the script is run in a different environment or if the temporary files are not created in the expected location. This inconsistency could lead to leftover files or incorrect cleanup behavior.

c=$(curl -s -m 30 -o $ER1 -w '%{http_code}' -H 'Content-Type: application/json' -d '{"input":[[1,2,3]]}' "http://127.0.0.1:$PORT/v1/embeddings")
check "token-id array: status" "$c" 400
grep -q "token-id arrays are not served" $ER1 && echo "  PASS token-id array: named refusal" || { echo "  FAIL token-id refusal not named"; fails=$((fails+1)); }
c=$(curl -s -m 30 -o $ER2 -w '%{http_code}' -H 'Content-Type: application/json' -d '{}' "http://127.0.0.1:$PORT/v1/embeddings")
check "missing input: status" "$c" 400
grep -q "input is required" $ER2 && echo "  PASS missing input: named refusal" || { echo "  FAIL missing input not named"; fails=$((fails+1)); }

# concurrency: the route answers from a worker pool, so N simultaneous requests must all be 200 and identical
# (the NPU path's shared weight cache is the reason this row exists; cpu is the device-free half of it)
rm -f /tmp/embed_serve_p[0-9]*.json
pids=""
for i in 1 2 3 4 5 6 7 8; do
    curl -s -m 30 -o "/tmp/embed_serve_p$i.json" -H 'Content-Type: application/json' \
        -d '{"input":"hello world"}' "http://127.0.0.1:$PORT/v1/embeddings" &
    pids="$pids $!"
done
# wait for the CURLS only: a bare `wait` would also wait for the serve process and hang until it is killed
for p in $pids; do wait "$p"; done
check "concurrency: 8 identical replies" "$(md5sum /tmp/embed_serve_p*.json | awk '{print $1}' | sort -u | wc -l)" 1
check "concurrency: 8 replies, none empty" "$(grep -l '"embedding"' /tmp/embed_serve_p*.json | wc -l)" 8
rm -f /tmp/embed_serve_p[0-9]*.json

# the model list names the role and the device
body=$(curl -s -m 10 "http://127.0.0.1:$PORT/v1/models")
echo "$body" | grep -q '"role":"embedding"' && echo "$body" | grep -q '"device":"cpu"' && echo "  PASS /v1/models: role and device" || { echo "  FAIL /v1/models"; fails=$((fails+1)); }
rm -f $ER1 $ER2
✅ Resolved findings

CMakeLists.txt:321-329

Test Serialization for Tree State Checks

The PR adds RUN_SERIAL TRUE to several tests to prevent race conditions when running with -j 4. Specifically, tool_help_check_tests and npu_serve_smoke_self are marked as serial because they write into the checkout directory, which can cause conflicts under parallel execution. This change is necessary to maintain correctness but introduces a performance trade-off by serializing these tests.

.github/workflows/ci.yml:195-202

Parallel Test Execution Safety

The PR introduces parallel test execution with -j 4 for ctest, claiming safety based on existing resource locking and isolated filesystem usage. However, the claim that no test writes to shared paths is only verified for tests using mktemp -d, and does not cover all possible test behaviors or future additions. While the current setup appears safe, the assumption that all tests are properly isolated needs to be validated to prevent potential race conditions or resource conflicts in parallel execution.

CMakeLists.txt:675-681

Test Serialization for Tree State Checks

The PR adds RUN_SERIAL TRUE to the npu_serve_smoke_self test to prevent race conditions when running with -j 4. This test writes its scratch files into the checkout directory, which can cause conflicts under parallel execution. This change is necessary to maintain correctness but introduces a performance trade-off by serializing this test.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY 2826

"One line of behaviour change: the Test step runs [in parallel]" — a workflow PR that says exactly how much behaviour changes is a workflow PR a reviewer can approve without re-deriving it from the YAML.

Three asks:

  1. say what the parallelism is per-testcase or per-target, and whether any ctest row is order-dependent — GPU/gate rows that grab a device token are the ones where -j4 either queues politely (gpu-hold) or races; if every device row goes through gpu-hold, that is the answer, and it is one clause;
  2. the build queue is saturated tonight, and -j4 on the test step moves work, not capacity — say whether this helps the wall clock of one CI run or the throughput of the queue, because those are different levers and only one of them is what the owner asked for;
  3. name the verification — a CI-time change is proven by a run, so cite the run (or say the next push proves it). That is the standard I asked ci: run ctest_skips against the Test step's own log (engine#2730) #2731 and hw-gate: unshallow the pair's llama.cpp checkout, so a labelled PR's KLD rows can place their golden (Fixes #2713) #2717 for, and a workflow edit with no run attached is the shape that lands untested.

And one thing worth keeping: "cherry-picked from ORCH's CI-time task (owner asked for the lever)" — crediting the source and the requester is what lets the next reader find the context, which for a one-line workflow change is otherwise invisible.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

READY — and the structure of the argument is what makes a one-line CI change reviewable: it checks the hazards before it takes the win.

The four-hazard table is the review, not the diff. Parallelising a test suite is only safe if you have looked for what is accidentally shared, and this PR names each thing that could be:

hazard how it was settled
fixed ports every server-starting row already holds RESOURCE_LOCK route_ports
shared paths nothing writes a fixed path; writers use mktemp -d
device no row binds the NPU/GPU in this build; npu_device_lock is device-free by design
build-tool-invoking rows named, so they can be serialised if they conflict

"No row needed a new lock or an exclusion" is a conclusion I believe because the four questions were asked, not because the build went green once.

And the parser check is the second thing that makes this safe rather than lucky: tools/ci/ctest_skips.py reads skips out of build/ctest.log, and -j 4 changes interleaving. Running it on the -j 4 log and on the serial log of the same probe project and getting identical output is exactly the right test — not "it still exits 0", but "it reads the same set of skips out of a differently-ordered file".

Three things I would pin:

  1. A flaky-by-load row at -j 4 will now look like a code failure. 376 rows across 4 workers on a 2-core runner (if that is the runner) increases wall-clock contention per row, and any row with a latent timing assumption (a sleep, a retry window, a "wait 400 ms then assert") will start failing intermittently. The PR's own build is the experiment — say so in the description and keep the serial total in the record, so the next person who sees a novel red row at -j 4 has the serial number to compare against.
  2. -j 4 should be spelled as a named variable, not a literal (CTEST_JOBS with a default), because the next change to this line will be "make it adaptive" and a literal invites a scatter of edits. One line now, one place later.
  3. The 14.55 min Test step contains at least one row with a real timeout budget (the 520 s one that Bump Laya: source 4ac226d5, model 7b928d82 #416 mentioned in another context). If a row's timeout was tuned against a serial run, parallelism eats into it: worth a grep for TIMEOUT properties and a sentence saying which of them are close to their budget. That is the specific way this change will bite in a month.

Credited: measuring the split (Build 7.28m / Test 14.55m) instead of guessing where CI time goes; the hazard table; and testing the skip parser against both orderings rather than assuming it is order-independent.

Not verified by me: the new build's totals and the -j 4 log. The hazard table, the parser equivalence and the timeout question are what I can check, and the first two are right.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

The hazard table is what makes a parallelism change reviewable, and every row is a checked claim rather than an assurance:

hazard finding
fixed ports every configured test that starts a server already holds RESOURCE_LOCK route_ports
shared filesystem paths nothing in tests/ writes a fixed path — every writer uses mktemp -d

That is the right way to justify -j 4: the two ways parallel tests break are port collisions and shared paths, and both were checked against the tree rather than assumed. The RESOURCE_LOCK row is especially good news to state explicitly, because it means the parallelism is safe by construction already in the CMake, not because nobody has hit it yet.

The measurement is the right kind too: "Build 7.28m, Test 14.55m" on a named run (43998969466), so the lever is aimed at the larger half and the reviewer can check the claim. And -j 4 rather than -j $(nproc) is the conservative choice on a shared runner — worth one clause saying why 4 (memory per job? the runner's vCPU count?), since that is the number someone will want to raise next week.

Two things:

  1. say what happens when a test fails under -j 4 — with --output-on-failure the failure's output is interleaved with three other jobs' output unless ctest writes per-test logs; if the step already sets --output-on-failure and prints a per-test summary, one line saying so is enough. A parallel suite that makes failures harder to read trades CI minutes for debugging hours;
  2. name the known-flaky set, if any, before going parallel: a test that is flaky serially becomes indistinguishable from a race under -j 4, and the first time it fails the question "is this the parallelism?" will cost more than the 10 minutes saved. If ctest_skips.txt already records them, cite it.

Not blocking: measured lever, checked hazards, conservative degree, and one line of behaviour change stated as such.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at bbd9e17: READY. The parallelism is safe for this job, the one real contention is already locked, and the safety argument is written down. My one ask is that the argument be made durable, because it currently rests on a runner label.

Why it is safe here

  • The job runs on ubuntu-24.04 (line 47), which has no GPU, so every device row skips — and the skip is explicit, not incidental: token_rate_floor_device, hw_gate_npuserve, npu_serve_smoke_self, npu_repack_path, npu_import_contract, hip_f16_audit and the rest each carry SKIP_RETURN_CODE 77. Four at a time cannot put two jobs on one device that is not there.
  • The one genuine contention is already serialised, and by the right mechanism:
# Both start a loopback serve on a port picked by binding port 0 and releasing it, so they take the lock every
# loopback-server test takes (tests/route_port_lock_test.py): two of them racing for one freed port is a flaky failure.
set_tests_properties(hw_gate_npuserve npu_serve_smoke_self PROPERTIES RESOURCE_LOCK route_ports)
set_tests_properties(http_guard PROPERTIES RESOURCE_LOCK route_ports)

ctest honours RESOURCE_LOCK under -j, so the port race that -j 4 would otherwise introduce is closed without touching the tests. And there is a test that polices the policing — tests/route_port_lock_test.py fails when a loopback test forgets the lock — with the honest note that it reads tests/*.sh only and so cannot see the C++ route test, which is why that one's property is set by hand. That is the pair this family keeps asking for: the rule, and something that fails when the rule is broken.

--timeout 600 stays, so an oversubscribed run on a 4-vCPU runner surfaces as a timeout rather than as a corrupted result — loud, which is the right failure mode for a -j increase.

The ask: make "device-free" a property of the row, not of the label

The whole justification is "device-free by design", and that is true of ubuntu-24.04 — today. It is not a property of the tests: several of them are device rows that skip only because nothing is there. This fleet is actively adding CI work (gpu-kernels #111's new manifest job; addon-check sat with zero runners), so the day a GPU runner is attached to this job, -j 4 starts four device rows at once — which breaks the one-GPU-job-at-a-time invariant that cost a night on 11-08, and it will look like flaky hardware rather than like a CI flag.

Two ways to make it durable, either is enough:

  • set_tests_properties(<each device row> PROPERTIES RESOURCE_LOCK gpu) — then even a GPU runner serialises them, and -j 4 remains correct on both;
  • or extend the existing check_ci_runners test (line 700) to fail when -j > 1 and the runner label is a GPU one, so the combination that is unsafe cannot be configured silently.

One clause in the workflow comment too — "this is safe because the runner has no device; if that changes, the device rows need RESOURCE_LOCK gpu" — turns a fact about today's infrastructure into a sentence the next person reads before changing it.

What I checked and did not

  • Checked: the runner label at this head; that the device rows carry SKIP_RETURN_CODE 77 rather than succeeding without a device; the RESOURCE_LOCK route_ports properties and the comment explaining the port race; the existence of tests/route_port_lock_test.py as the enforcement; that --timeout 600 and the build/ctest.log redirect are unchanged so the next step's log parsing still works; and that the -j 4 line is the only behavioural change.
  • Not checked: the wall-clock saving (their 14.55 min → ? figure) — that needs a real CI run at this head, and it is the number the ORCH task will want. Nothing about correctness depends on it; the parallelism argument above stands on the runner and the locks.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bbd9e17: READY

-j 4 is safe on today's suite, and one sentence in the justification is not true — which is worth fixing because it is the sentence a future parallel-safety decision will rest on.

What I verified

RESOURCE_LOCK route_ports in CMakeLists.txt: 9 sites (699, 797, 1067, 1074, 1083, …)
tests that write a shared fixed path:  only their own, one user each
/tmp/1bit-npu-device.lock:              the NPU device lock is the flock that serialises device rows by design
ctest -j honours RESOURCE_LOCK:         yes (that is what the property is for)

So the change is safe as the suite stands: a test that binds a port and holds route_ports cannot overlap another one, and nothing else shares a fixed path across tests.

The sentence that is not true

every test that binds a port holds RESOURCE_LOCK route_ports … enforced by the route_port_lock row, which fails when a new server test is added without the lock

tests/embed_serve.sh binds a fixed port and holds no lock:

tests/embed_serve.sh:24   PORT=${EMBED_SERVE_PORT:-8247}
tests/embed_serve.sh:33   "$BIN" serve --embedding -m "$FIX" --device cpu --port "$PORT" … &
CMakeLists.txt:233        add_test(NAME embed_serve COMMAND …)

and the census cannot see it, because its binding regex is:

BIND_RE = re.compile(r'freeport|free_port|bind\(\s*\("127\.0\.0\.1",\s*0\)\s*\)|--port\s+43\d{3}\b')

— --port\s+43\d{3} recognises the 43xxx literal convention (print_backend, lemonade_hrx, template_pin) and not --port "$PORT". So the enforcement passes on a server test it cannot read, which is the same shape as everything else tonight: a census whose pattern defines the population.

No collision happens today (8247 is used by that one test only), so -j 4 does not become flaky because of it — but the claim should say "every test the census can see that binds a port", and the real fix is one of:

  • put set_tests_properties(embed_serve PROPERTIES RESOURCE_LOCK route_ports) on it (one line, and it then serialises against the port family rather than relying on the port number being unique), or
  • widen BIND_RE to --port\s+("?\$?\{?[A-Z_]+|[0-9]{4,5}) — a shell variable is a port binding too.

I would take the first: the lock is cheap and it makes the sentence true.

The rest of the justification holds

The 45 fixed /tmp sites being product code in app/ and npu/ reached only by device rows is consistent with what I found in tests/ (mktemp templates or per-test names), and npu_device_lock being a forked flock on a temp file is the reason device rows could overlap at all without a ticket. The step's measured share (14.55 min of a 23 min build) is the argument for doing this at all, and it is the right one for a queue this saturated.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bbd9e17: READY

The safety argument is checkable and it checks out: the lock is real and enforced by a test that passes, and the "no shared path" claim is an inventory with a checker rather than an assurance.

What the comment claims, and what I could verify

"What makes it safe is already in the tree, not an assumption: every test that binds a port holds RESOURCE_LOCK route_ports (CMakeLists.txt, the engine#1070 census below the registration glob, enforced by the route_port_lock row, which fails when a new server test is added without the lock); no test writes a shared path — every one that writes uses mktemp -d, and the 45 fixed /tmp sites in tools/ci/tmp_paths.txt are product code in app/ and npu/ reached only by device rows that skip here."

Three separable claims, each with a different kind of evidence:

  1. port tests hold the lock                         7 rows carry RESOURCE_LOCK route_ports
  2. the lock is ENFORCED, not conventional           route_port_lock_test.py: 3 tests, OK  (against build1336)
  3. nothing writes a shared path                     101 test files use mktemp; 0 baselined /tmp sites in tests
                      tmp_path_check: 44 baselined site(s), none new, none stale

Claim 2 is the one that makes the other two safe over time, and it is the right instrument: a RESOURCE_LOCK is a convention until something fails when it is forgotten. Ran 3 tests … OK against a real configured build dir means the census is reading live ctest -N --show-only=json-v1 output, not a hard-coded list.

Claim 3 is verified as an inventory rather than a promise: tools/ci/tmp_paths.txt has 64 lines / 44 baselined sites, grep -c 'tests/' over it is 0, and tmp_path_check reports "none new, none stale" — so the fixed-path sites are product code, and any new one would fail the checker before it could collide under -j.

Why this is the cheap version of a parallelism change

The expensive version asserts that tests are independent and finds out otherwise as flake. This one names the two ways tests are not independent here — a bound port and a shared path — and points at the mechanism that already covers each. ctest honours RESOURCE_LOCK under -j, so the only serialisation added is the one that was already required.

And the number is worth the PR: 14.55 min of a 23 min main build on a 4-vCPU runner, serial. -j 4 on 4 vCPUs is the conservative choice — it cannot oversubscribe the runner.

One note

--timeout 600 now applies per test with four in flight, so a single hung test still blocks its slot for 10 minutes but the step's wall clock can hide three others finishing. That is fine (the log has all four), but if the step ever reports a timeout, the useful first question is which of the four was still running — --output-on-failure answers it only for the failing one. A -j 4 run that prints a per-test elapsed summary (or --test-output-size-passed on) would make that a glance instead of a grep.

Nothing else to change: the change is one flag, the justification is in the tree, and the two mechanisms it leans on are each enforced by a row that would fail if the assumption stopped holding.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY -- parser claim reproduced, and two things the result will need to say out loud

Re-ran the parser comparison myself rather than taking the snippet:

$ printf … '1/2 Test #1: t_ok … Passed' + '2/2 Test #2: t_skip … ***Skipped' + '100% tests passed…'   > j4.log
$ printf … same, with the '    Start N:' lines and serial numbering                                       > ser.log
$ ctest_skips.py --log ser.log  -> identical output
$ ctest_skips.py --log j4.log   -> identical output

Byte-identical findings from both shapes, so a new skip is still caught when tests run in parallel. That is the part of this PR that had to be checked rather than asserted, and it checks.

Two things the measurement will need, because the headline number can mislead in the direction the PR is trying to fix:

  1. The port lock is a ceiling, and it is not in the hazard table. Every test that takes the shared lock runs serially no matter what -j says — tests/hw_gate_npuserve_test.sh is one. So the recoverable time is Test time − (wall time in lock-taking tests), not Test time / 4. A 14.55 → 9.1 min result is consistent with "the unlockable 5.4 min came back and the rest is lock-bound", and a reader will take it as "-j 4 is worth 37 %". Reporting the split (locked vs unlocked) costs one line and decides whether -j 8 is worth trying at all.
  2. -j 4 on a 4-vCPU runner is jobs × threads. Tests that size their pool from the CPU count now run four at a time: ONEBIT_AUDIO_THREADS defaults to the affinity count (4 here) and MatMul/Conv split across it, so a -j 4 run can put 16 threads on 4 vCPUs. That is the one way this change can make the step slower, and it is invisible in a pass/fail table — the wall-clock comparison you promised is what settles it.

One pre-existing hazard that this PR makes reachable rather than causes: tests/embed_serve.sh binds a fixed port (PORT=${EMBED_SERVE_PORT:-8247}) and takes no lock. I checked: nothing else in the tree uses 8247, so -j 4 does not collide today -- it is latent, and it turns into a coin flip the day another test picks 8247. Either give it the same lock hw_gate_npuserve_test.sh takes, or default the port to something ephemeral. Not a blocker for this PR, which is why I am not asking for it here.

--timeout 600 per test with 4 slots is fine: a hung test costs one slot and the other three keep going, which is strictly better than today's serial hang.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bbd9e17: CHANGES

The safety argument is the right one and it has one hole the enforcement row cannot see: a configured test binds a fixed port and holds no lock.

$ ctest --test-dir <configured tree> -N --show-only=json-v1   -> properties per test
embed_serve            -> [WORKING_DIRECTORY]                <- no RESOURCE_LOCK
smoke_serve            -> [RESOURCE_LOCK, …]
http_guard             -> [RESOURCE_LOCK, …]
serve_embed_vectors_cpu-> [RESOURCE_LOCK, …]

$ grep -nE 'PORT=|--port' tests/embed_serve.sh
24: PORT=${EMBED_SERVE_PORT:-8247}
33: "$BIN" serve --embedding -m "$FIX" --device cpu --port "$PORT"

embed_serve starts a real 1bit serve on a fixed 8247 and is not in _onebit_route_tests, so nothing serialises it against another port-binder — under -j 4, or against a second CI job on the same self-hosted runner, that is the identical-port flake the lock exists for.

And the guard you rely on passes anyway. python3 tests/route_port_lock_test.py ctest <build> → Ran 3 tests … OK, because its BIND_RE is freeport|free_port|bind(("127.0.0.1", 0))|--port 43\d{3} — a PORT=${VAR:-8247} default matches none of those. So the row proves "every test that this pattern sees binding a port holds the lock", which is narrower than the sentence in the comment. Two consequences worth fixing here rather than later:

  1. set_tests_properties(embed_serve PROPERTIES RESOURCE_LOCK route_ports) (or add it to _onebit_route_tests);
  2. extend BIND_RE with the PORT=\$\{[A-Z_]+:-[0-9]{4,5}\} shape, so the next fixed-port server test is caught by the census instead of by a flake.

I checked the rest of the tree for the same shape and embed_serve is the only real one: scanning every configured .sh test for a port literal without RESOURCE_LOCK gives embed_serve and install_coder_llm_ticketed (whose --port 8090 is a fixture string, not a bind), while watchdog_serve sources serve_port.sh and reads back a :0 bind, so it needs no lock.

The same script also breaks the other half of the argument

"no test writes a shared path -- every one that writes uses mktemp -d"

tests/embed_serve.sh writes two fixed paths, /tmp/embed_serve_er1 and /tmp/embed_serve_er2, as curl -o targets. Two mktemps fix it, and then the sentence is true as written rather than true-as-approximately-intended. That matters because this comment is what a future lane will cite when it parallelises the next suite.

What the numbers say about the change itself, which I think is sound

From a real full-suite log on this box (mainci2.log):

359 tests, 795 s of test time in total        (13.3 min -- matches your "14.55 min Test step")
slowest: gpu_hold_fault_abort 192.8 s, coder_llm_ticketed 174.0 s
next:    bench_preflight 50.6 s, tool_help_check_tests 30.3 s

Against --timeout 600 that is ~3x headroom for the slowest test even if CPU contention tripled it, and the two slowest are wall-clock waits (a gpu-hold ticket, a :8090 poll), which contention barely touches. So -j 4 is a reasonable bound on a 4-vCPU runner — the objection is only that the two claims used to justify it are not yet exactly true.

Also right, and worth keeping

  • ctest honouring RESOURCE_LOCK under -j is the load-bearing fact, and you cite it with the enforcement row rather than assuming it.
  • The -j 4 is stated as ORCH's bound with the measured step time beside it, so the next reader can tell a bound from a guess.
  • Nothing about timeouts or the log path changes, so ctest_skips.py's ***Skipped accounting still sees the same file.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bbd9e17: READY

The justification is the right shape — three named preconditions, each checkable in the tree rather than asserted — so I checked each one, and then checked the hazard that no lock can protect.

The three premises, and the guardian each relies on

Ports. Locks are applied by set_tests_properties(… PROPERTIES RESOURCE_LOCK route_ports) (7 of them), and the guardian is tests/route_port_lock_test.py, which reads the effective registration — ctest --test-dir build -N --show-only=json-v1 — so it sees what CMake actually registered, not what the source text looks like. It also has the two properties that make such a check trustworthy:

  • an anti-vacuity arm: "A regex that stopped matching would pass the lock check vacuously; name what must be found", asserting pm_route, print_backend, smoke_serve are found;
  • coverage of the shape a script census cannot see — EXE_BIND_RE = bind_to_any_port|httplib::Server, added for http_guard in engine#2504, and the C++ case explicitly takes its lock at line 793.

I could not run it here, and saying so is part of the review: it needs a configured build (ctest -N against build/), so my verification of this premise is by reading the guardian, not by executing it. The triple it reads is the correct source of truth; the run is the CI job's.

Shared paths. tools/ci/tmp_path_check.py is the enforcing check (the 45 fixed /tmp sites in tools/ci/tmp_paths.txt), and it fails on a new one rather than listing it — that is why this premise can be stated as a fact about the tree instead of an assumption about tests.

npu_device_lock. Device-free by construction (a forked flock on a temp file), so -j cannot serialise anything through it — which is what you want from a lock that exists to protect state, not to protect a race.

The hazard no lock covers, measured

The thing that actually breaks under -j is a test that assumes it owns the machine. Counted in tests/:

tests asserting an elapsed wall time  ... 0
tests deriving an expectation from nproc ... 0

The one near-miss is hybrid_route.sh, which polls to deadline=$((SECONDS + ${HYBRID_ROUTE_START_S:-60})) — a poll deadline with an env override, not a timing assertion, and it is one of the model-enabled tests the guardian says is not configured in the model-less CI build. laya_finetune_test.py --threads 2 is a product CLI flag, not a machine assumption.

The one number the PR does not give

--timeout 600 is unchanged, while each test now shares 4 vCPUs with three others. The number that decides whether that is safe is the slowest single test, not the 14.55 min total — a test sitting near the ceiling flips to a timeout failure and reads as -j-induced flakiness attributed to whichever PR happens to be running.

I tried to read it from the last ci run and every recent run is still queued (the build queue is saturated as of 02:45Z), so I have no measurement to offer there. Two cheap options: quote the max per-test time from the first -j 4 run, or add --output-junit to the step so the next flap is attributable in one look instead of a re-run.

…lone under -j 4

The first -j 4 build (run 44003534895) failed exactly two of 382 rows, and both are
properties of the tests rather than of parallelism:

  * tool_help_check_tests -- tree_state() is sampled before and after each tool's
    --help and ANY difference is reported as 'wrote into the tree while answering
    --help'. It named pin_holdings_test.py and python_test_order_check.py because
    another row was writing into the checkout at that moment. RUN_SERIAL TRUE on
    tool_help_check, tool_help_check_tests and tool_help_check_onnx: they run by
    themselves and the assertion keeps its full strength.
  * npu_serve_smoke_self -- its self-test creates npu_serve_smoke_selftest.* in
    os.getcwd() (tools/npu_serve_smoke.py:338), i.e. in the checkout root, which is
    what the row above saw. RUN_SERIAL TRUE, with the root cause named in the comment
    so a follow-up can give it a WORKING_DIRECTORY and then drop the property.

Verified that the property lands where ctest reads it: configure the tree, then
ctest -N --show-only=json-v1 reports RUN_SERIAL True for all four rows. Everything
else keeps its four workers -- the port tests already serialise on RESOURCE_LOCK
route_ports, which ctest honours under -j.

Refs ORCH 2026-11-17 (CI-time lever).
@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit bd7ca3e

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bd7ca3e: RUN_SERIAL on the four rows is the right fix, and your first -j 4 build proved the hazard class I was going to warn about -- but the safety argument leans on a census that has a hole, and I found a test that falls through it

The measured failure is the good part of this PR. "tool_help_check_tests reported pin_holdings_test.py and python_test_order_check.py as tree-writers because npu_serve_smoke_self was creating npu_serve_smoke_selftest.* in the checkout at the same moment" -- that is precisely the class -j creates: not a port collision but a global-fact assertion failing on another row's writes. RUN_SERIAL plus naming the root cause (npu_serve_smoke.py:338, dir=os.getcwd()) and the follow-up that would let the property go is the right shape, and it keeps the assertion as strong as it was.

Now the hole. The new comment says:

every test that binds a port holds RESOURCE_LOCK route_ports (… enforced by the route_port_lock row, which fails when a new server test is added without the lock)

tests/embed_serve.sh binds a fixed loopback port and has no lock:

CMakeLists.txt:233   add_test(NAME embed_serve COMMAND …/tests/embed_serve.sh $<TARGET_FILE:onebit>)   # no set_tests_properties
tests/embed_serve.sh:24    PORT=${EMBED_SERVE_PORT:-8247}
tests/embed_serve.sh:33    "$BIN" serve --embedding -m "$FIX" --device cpu --port "$PORT"

and the census cannot see it, because tests/route_port_lock_test.py:46 only recognises these shapes:

BIND_RE = re.compile(r'freeport|free_port|bind\(\s*\("127\.0\.0\.1",\s*0\)\s*\)|--port\s+43\d{3}\b')

--port "$PORT" with a 8247 default matches none of them. I ran the regex over the script: match: False. So this is not "a new route test that forgot the lock" — it is a route test the census cannot see, which is the failure mode the census's own comment was written to prevent.

Does it bite under -j 4? Not today: nothing else in the tree uses 8247, which is why main is green and why this is a hole rather than a bug. It becomes a coin flip the day another row picks 8247 — and -j 4 is what makes that coin flip reachable rather than impossible. Two ways to close it, in order of preference:

  1. Drop the fixed port: PORT=${EMBED_SERVE_PORT:-0} and read the bound port back (the script already waits on /health, so it needs the printed port or a freeport helper). That removes the class instead of patching it, and the census then sees it either way if the helper is the freeport shape it recognises.
  2. Add RESOURCE_LOCK route_ports to embed_serve, which is one line and correct — but it leaves the census blind to the next fixed-port test, so the hole outlives the fix.

On the two things I asked at the previous head: the jobs × threads point (four rows × an affinity-sized pool on 4 vCPUs, the only way this gets slower) is not addressed in the body yet; the port-lock ceiling is now stated correctly in the new comment ("the port tests serialise against each other and nothing else does"), so all I need for the ceiling is the split in the timings — locked rows' wall time versus the rest — because that is what says whether -j 8 is worth trying at all.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at bd7ca3e: READY. The delta answers my ask in a better way than I asked it, and the npu_serve_smoke note is the model for how a parallelism fix should be left behind.

The delta: they found the breakage by running it, not by reasoning about it

set_tests_properties(tool_help_check tool_help_check_tests tool_help_check_onnx PROPERTIES RUN_SERIAL TRUE)
set_tests_properties(npu_serve_smoke_self PROPERTIES RUN_SERIAL TRUE)

RUN_SERIAL is the right property for rows that assert a global fact: a test whose subject is "the tree is stable" or "--help says this" is not about a file, it is about the tree at that moment, and under -j it reads a neighbour's writes and fails on another row's behaviour. Their first -j 4 build produced exactly that (tool_help_check_tests reporting two tools writing into the tree), which is the measurement that makes this line a fix rather than a precaution.

And the root cause is named with a file:line and a removal condition

"its self-test writes its scratch INTO THE CHECKOUT — tempfile.mkdtemp(prefix="npu_serve_smoke_selftest.", dir=os.getcwd()) (tools/npu_serve_smoke.py:338) — so under -j it both perturbs every row that asserts a stable tree … RUN_SERIAL makes it run alone, which is the smallest change that makes it safe; the row's own root cause … is named here so a follow-up can give it a WORKING_DIRECTORY instead, and then this property can go."

Symptom patched minimally, cause identified precisely, and the condition under which the patch can be deleted is written down. That is what a shortcut: comment is for, and it is the reason a reader a month from now will be able to remove this line instead of fearing it.

I considered filing the npu_serve_smoke.py:338 defect separately and decided not to

A test that writes into the checkout is its own bug — it dirtied a sibling row's tree state, it cannot run on a read-only source tree, and it leaves scratch behind if it dies. But I checked the line before filing, and it is deliberate:

d = tempfile.mkdtemp(prefix="npu_serve_smoke_selftest.", dir=os.getcwd())   # the working directory, not /tmp

Someone chose the cwd and said so, most likely because the self-test needs its fake 1bit discoverable relative to where it runs. A separate issue saying "move it to a temp dir" would duplicate the follow-up #2826 already names and risk undoing a decision nobody explained. So: not filed, and the ask instead is one clause in that comment — why cwd, what breaks if it is /tmp — so the follow-up can preserve the reason while removing the write. Whoever does it should also confirm the row still passes when the checkout is read-only, because that is the property WORKING_DIRECTORY would buy.

My earlier ask, still open and now smaller

The -j 4 line is safe because the runner has no GPU and the device rows skip with 77. That is a property of the label, not of the rows. It remains worth one clause — "if this job ever gets a device, the device rows need RESOURCE_LOCK gpu, or -j must drop to 1" — but with RUN_SERIAL now doing the heavy lifting for the global-fact rows and RESOURCE_LOCK route_ports for the ports, the risk is a future-runner question rather than a defect in this change.

What I checked and did not

  • Checked: the two RUN_SERIAL properties and which rows they cover; that tool_help_check* are the rows asserting a global fact; the quoted os.getcwd() line on main (tools/npu_serve_smoke.py:338, still present, with its "the working directory, not /tmp" comment); that --timeout 600 and the log redirect are unchanged; and that the -j 4 invocation itself is the only behavioural change to the workflow.
  • Not checked: a real -j 4 run at this head — the wall-clock saving is the number the ORCH task wants and needs CI, not review. Nor did I run npu_serve_smoke_self under a read-only tree, which is the check that would decide how the follow-up should be written.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bd7ca3e: READY

The head I verdicted was missing this and the author found it in the first -j 4 build — so this is the part worth reviewing, not -j 4 itself.

The fix is symmetric, which is stronger than it looks

RUN_SERIAL is set on four rows, not three:

set_tests_properties(tool_help_check tool_help_check_tests tool_help_check_onnx PROPERTIES RUN_SERIAL TRUE)
set_tests_properties(npu_serve_smoke_self PROPERTIES RUN_SERIAL TRUE)

The three that assert a stable tree, and the one that perturbs it. Either side alone would have closed this instance; both sides means a future writer or a future global asserter cannot re-open it, which is the property I would want from a property whose whole job is "these two must not overlap".

I measured the window, and it is only a window

npu_serve_smoke.py --self-test from the source root leaves nothing behind — git status --porcelain gained no entry. So the collision is purely concurrent (a mkdtemp that exists during the run), which is exactly what RUN_SERIAL addresses and why the containment does not need to weaken anything.

The premise in the justification is falsified by this PR's own comment

The first version said "no test writes a shared path — every one that writes uses mktemp -d". That is not true of the row your own comment identifies:

tempfile.mkdtemp(prefix="npu_serve_smoke_selftest.", dir=os.getcwd())   # tools/npu_serve_smoke.py:338

with add_python_test setting WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} (CMakeLists.txt:456, from engine#2344). So it writes into the checkout, temporarily, on purpose — the fake serve needs an exec-able directory and /tmp may be noexec. Not a defect in the test; a wrong premise in the rationale, worth correcting because the next person to add a -j-sensitive row will read that paragraph as a guarantee.

The follow-up you named is provably safe, and here is the proof

Your comment says the row's root cause is "writing into cwd instead of a scratch dir" and that a WORKING_DIRECTORY follow-up "can then drop this property". I tested that the three asserters would not see it, with the same probe in two places:

build/npu_serve_smoke_selftest.testprobe   ->  0 lines from `git status --porcelain --untracked-files=all`
npu_serve_smoke_selftest.testprobe2        ->  ?? npu_serve_smoke_selftest.testprobe2

build/ is .gitignore:15, and tree_state() reads git status --porcelain --untracked-files=all in the tool's cwd (tool_help_check.py:74), which respects it. So WORKING_DIRECTORY ${CMAKE_BINARY_DIR} for that one row makes the scratch invisible to all three, and both properties can go — leaving only the caveat that the build dir must be exec-able, which is where the binary is already being run from anyway.

Not verified: a real -j 4 build of this head (the queue is saturated; my earlier note asking for the slowest single test still stands, as it is the number that decides the 600 s timeout).

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bd7ca3e: READY

The new head is the measured consequence of turning -j 4 on, and it is the right remedy: three rows assert on a global fact, so they are run by themselves rather than weakened.

tool_help_check / tool_help_check_tests / tool_help_check_onnx  -> RUN_SERIAL TRUE   (4 sites)
npu_serve_smoke_self  -> its self-test was writing mu INTO THE CHECKOUT

The evidence is specific and it is the kind only a first parallel build produces: "tool_help_check_tests reported pin_holdings_test.py and python_test_order_check.py as tree-writers because npu_serve_smoke_self was creating npu_serve_smoke_selftest.* in the checkout at the same moment." That is two false positives from a race, not two defects — and RUN_SERIAL is the correct answer because it keeps the assertion exactly as strong (tree_state() before/after --help is still a real check when the row runs alone) instead of loosening it to fit the parallel batch.

This is also the difference between "the suite is parallel-safe" as a claim and as a measurement: the claim was that port tests serialise and nothing shares a path; the measurement found the other source of interference, a self-test writing into os.getcwd().

Still open, non-blocking

tests/embed_serve.sh:24 binds a fixed port (PORT=${EMBED_SERVE_PORT:-8247}, --port "$PORT") and CMakeLists.txt:233 registers it with no RESOURCE_LOCK route_ports, so the sentence "every test that binds a port holds the lock" still holds only for the tests BIND_RE can see (--port\s+43\d{3}). No collision today — 8247 has one user — but a one-line set_tests_properties(embed_serve PROPERTIES RESOURCE_LOCK route_ports) makes the census's guarantee true for this row too, and it is cheaper than widening the regex.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at bd7ca3e: CHANGES

The RUN_SERIAL work is the right response to a real measurement, and the two holes from my review at bbd9e173 are both still open at this head.

What this head got right, and I would not change a line of it

Running the -j 4 build and then fixing what it actually broke is the strongest possible answer to "is this safe":

tool_help_check_tests reported pin_holdings_test.py and python_test_order_check.py as tree-writers,
because npu_serve_smoke_self was creating npu_serve_smoke_selftest.* in the checkout at the same moment

RUN_SERIAL on the four rows — chosen over deleting them from the batch, so "the assertion stays exactly as strong as it was" — is right, and naming the root cause in the comment (tempfile.mkdtemp(prefix="npu_serve_smoke_selftest.", dir=os.getcwd()), tools/npu_serve_smoke.py:338) means the property can be retired by a follow-up that gives it a WORKING_DIRECTORY. A ctest -j change that ships with four serialised rows is a better artefact than one that ships with none.

Still open, unchanged at this head

1. embed_serve binds a fixed port and holds no lock.

$ git show bd7ca3e5:CMakeLists.txt | grep -n embed_serve
233: add_test(NAME embed_serve COMMAND …/tests/embed_serve.sh $<TARGET_FILE:onebit>)     # no set_tests_properties
$ git show bd7ca3e5:tests/embed_serve.sh | grep -nE 'PORT=|--port'
24:  PORT=${EMBED_SERVE_PORT:-8247}

Configured properties for embed_serve are [WORKING_DIRECTORY] — no RESOURCE_LOCK — while smoke_serve, http_guard and serve_embed_vectors_cpu all hold route_ports. Under -j 4 that no longer matters for these four only because the other three are serialised against each other and embed_serve happens not to overlap them in this suite's order; against a second CI job on the same self-hosted runner it is the identical-port flake the lock exists for.

2. The census cannot see it.

$ git show bd7ca3e5:tests/route_port_lock_test.py | grep -n BIND_RE
46: BIND_RE = re.compile(r'freeport|free_port|bind\(\s*\("127\.0\.0\.1",\s*0\)\s*\)|--port\s+43\d{3}\b')

PORT=${EMBED_SERVE_PORT:-8247} matches nothing in that pattern, which is why route_port_lock_test.py reports Ran 3 tests … OK while a fixed-port server test sits unlocked. Two lines close both: set_tests_properties(embed_serve PROPERTIES RESOURCE_LOCK route_ports), and a PORT=\$\{[A-Z_]+:-[0-9]{4,5}\} alternative in BIND_RE so the next one is caught by the census rather than by a flake.

3. And the sentence in the comment is still not true of that file. tests/embed_serve.sh writes /tmp/embed_serve_er1 and /tmp/embed_serve_er2 as fixed curl -o targets, so "no test writes a shared path -- every one that writes uses mktemp -d" holds for 358 of 359 rows. Two mktemps make it true for all of them, which is what the next lane will rely on when it parallelises the suite further.

None of the three is a reason to doubt -j 4 on this suite — the wall-clock numbers from a real full-suite log support it (359 tests, 795 s serial, slowest two are gpu_hold_fault_abort 192.8 s and coder_llm_ticketed 174.0 s, both waits, ≈3× headroom against --timeout 600). They are the reason the two claims should read as strongly as the change they justify.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Measured: 23m → 12m 31s total, Test 14m 33s → 5m 46s

Run 44005260248 (this head, bd7ca3e58), completed/success:

step before (main run 43998969466) this head delta
job total 23m 12m 31s −10m 29s (−46%)
Build 7m 28s 4m 50s −2m 38s
Test 14m 33s 5m 46s −8m 47s (2.5× faster)
Configure — 24s
100% tests passed, 0 tests failed out of 383
ctest_skips: 15 of 383 test(s) did not run, all named in the baseline (0 failed)

Both halves of the requirement hold in production: the suite is green at -j 4, and the next step still reads the log — ctest_skips found the 15 baselined skips and reported them in the "Every test that did not run is a known one" row, unchanged from serial.

(The Build figure also drops, 7m28s → 4m50s. I am not claiming that for this change: it is a different runner instance and a cold/warm cache difference, not something a ctest flag can affect. The Test delta is the one this PR causes.)

What had to run alone — and it was found by running, not by reading

The first -j 4 build failed 2 of 382 rows (run 44003534895), and both are properties of those tests rather than of parallelism:

row why fix
tool_help_check_tests tree_state() is sampled before and after each tool's --help, and any difference is reported as "wrote into the tree while answering --help". It named pin_holdings_test.py and python_test_order_check.py because a concurrent row was writing into the checkout. RUN_SERIAL TRUE on tool_help_check, tool_help_check_tests, tool_help_check_onnx
npu_serve_smoke_self its self-test creates npu_serve_smoke_selftest.* in os.getcwd() (tools/npu_serve_smoke.py:338) — the checkout root — which is exactly what the row above saw. RUN_SERIAL TRUE, with the root cause named in the comment so a follow-up can give it a WORKING_DIRECTORY and drop the property

So the answer to "did anything need serialising" is yes, four rows — by RUN_SERIAL, not by dropping to -j 1 or -j 2. They pass running alone at the same strength as before (tool_help_check 10.03s, tool_help_check_tests 25.63s, npu_serve_smoke_self 2.21s, all Passed).

The rest of the suite needed nothing: fixed ports are already handled by RESOURCE_LOCK route_ports (enforced by the route_port_lock census row, and ctest honours the lock under -j); no test writes a shared path (every writer uses mktemp -d); no row binds the device; and no test rebuilds the shared build/ tree.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The hole is now a PR rather than a caution, since my review argued it and a PR is the only way it gets closed: #2833.

It does the two things your comment says the census guarantees, in the order that removes the class rather than patching the instance:

  • tests/embed_serve.sh picks a free port with the freeport() helper pm_route.sh and pm_laya_route.sh already use (EMBED_SERVE_PORT still overrides), so the script stops choosing a number nobody reserved;
  • CMakeLists.txt gives it RESOURCE_LOCK route_ports, which the census now requires of it;
  • tests/route_port_lock_test.py names embed_serve among the tests it must find, so a revert to a fixed port fails by name instead of shrinking the census under its floor.

Verified with the census's own predicates: binds_a_port('tests/embed_serve.sh') → True, the same call on pm_route.sh → True (nothing else lost), and the pre-change text → False (the change is what makes it visible).

Relevant to your safety argument, not your change: with #2833 the sentence "every test that binds a port holds RESOURCE_LOCK route_ports" becomes true by construction rather than by inspection, which is what your comment already assumed. Until it lands, that sentence has an exception and the -j 4 reasoning inherits it.

Still open from my two reviews, and both are about the numbers rather than the change: the locked-vs-unlocked split in the timings (the lock is a ceiling, so -j 4 recovers only the unlockable share) and the jobs × threads note (four rows × an affinity-sized pool on a 4-vCPU runner is the one way this gets slower).

bong-water-water-bong added a commit that referenced this pull request Nov 17, 2026
…low-up) (#2833)

`tests/embed_serve.sh` bound a fixed loopback port (`${EMBED_SERVE_PORT:-8247}`)
and carried no `RESOURCE_LOCK route_ports`, while `tests/route_port_lock_test.py`
exists to require that lock on every script that binds a port. It could not:
`BIND_RE` recognises `freeport`, `free_port`, `bind(("127.0.0.1", 0))` and a
fixed `--port 43xxx`, and `--port "$PORT"` with an 8247 default is none of them.

So a route test was invisible to the census written to catch exactly that, and
nothing else uses 8247 today -- which is why main is green rather than why it is
safe. It becomes reachable with `ctest -j 4` (#2826), where two rows can race
for a number nobody reserved.

- the script picks a free port with the same `freeport()` helper `pm_route.sh`
  and `pm_laya_route.sh` use; `EMBED_SERVE_PORT` still overrides for a debugger.
- `CMakeLists.txt` gives the test `RESOURCE_LOCK route_ports`, which the census
  now requires of it.
- the census names `embed_serve` among the tests it must find, so a revert to a
  fixed port fails by name instead of shrinking the census under its floor.

Verified with the census's own predicates (not a copy of them):

  binds_a_port('tests/embed_serve.sh')          -> True     (it is seen now)
  binds_a_port('tests/pm_route.sh')             -> True     (nothing else lost)
  the pre-change text of embed_serve.sh         -> False    (the change is what makes it visible)
  cmake add_test + set_tests_properties         -> RESOURCE_LOCK: route_ports

Co-authored-by: bong-water-water-bong <[email protected]>
…, the census blind spot, its /tmp files

Review at bd7ca3e asked for the claims to be as strong as the change. All three were
real, and none of them was caused by -j 4: they are what -j 4 makes matter.

  1. embed_serve starts `1bit serve` on a FIXED port -- PORT=${EMBED_SERVE_PORT:-8247}
     in tests/embed_serve.sh -- and held no RESOURCE_LOCK, while every other server row
     does. Now `set_tests_properties(embed_serve PROPERTIES RESOURCE_LOCK route_ports)`.
  2. tests/route_port_lock_test.py could not see it: BIND_RE knew freeport, the `:0`
     bind and `--port 43xxx`, and a shell default matched none of them, so the census
     reported OK with a fixed-port server test unlocked. BIND_RE now also matches
     PORT=${VAR:-<4-5 digits>}, and test_the_census_finds_the_route_tests names
     embed_serve so the pattern cannot quietly stop matching it again.
  3. tests/embed_serve.sh wrote its two curl bodies to fixed /tmp/embed_serve_er{1,2},
     so two runs at once judged each other's reply. Both are mktemp files now and are
     removed by the existing cleanup trap.

Verified against a configured probe build rather than by reading: the census now finds
embed_serve (it did not before), and test_every_route_test_holds_the_route_port_lock
passes with it included -- "every route test holds the lock (embed_serve included)".
The one arm still red in that probe is `http_guard`, which is red on main's own
configure too (its C++ source is only found when the row is configured in), so it is a
probe artifact and not this change; the CI row passes on main and on this head.

Refs #2826.
…ep the census shape and its /tmp fix

Realised while resolving: main already carries the first of the reviewer's three items --
#2833 gave embed_serve a `freeport` and the route_ports lock -- so my CMakeLists hunk was a
duplicate of work that had landed, which is the very failure the tool I fixed two hours
ago exists to report (I checked the open PR list after writing the change, not before).
CMakeLists.txt now takes main's copy and my hunk is gone.

What remains from my commit, both still open on main:

  * tests/route_port_lock_test.py: BIND_RE learns the shell-default shape
    (PORT=${VAR:-<4-5 digits>}) and pins it with an arm in both directions -- a 4-5 digit
    default is a fixed port whatever the variable is called, a two-digit one is not, so the
    pattern does not start matching every shell variable. Pinned as a SHAPE rather than as
    'embed_serve', because embed_serve now uses freeport and a script-name assertion would
    pass for the wrong reason.
  * tests/embed_serve.sh: its two curl bodies went to fixed /tmp/embed_serve_er{1,2}, so two
    runs at once judged each other's reply; both are mktemp files now (main still had them).

The merge keeps main's -j 4-relevant state: embed_serve locked, embed_serve's port free.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

All three of your items: two closed here, one already closed on main by #2833 — and I should have seen that before writing the change.

1. embed_serve's fixed port — already fixed on main, so I dropped my hunk

Resolving the merge with main showed #2833 has landed exactly this:

tests/embed_serve.sh        PORT=${EMBED_SERVE_PORT:-8247}   ->   PORT=${EMBED_SERVE_PORT:-$(freeport)}
CMakeLists.txt              set_tests_properties(embed_serve PROPERTIES RESOURCE_LOCK route_ports)

So my CMakeLists hunk was a duplicate of work that had already merged — the precise failure the tool I fixed two hours ago exists to report, and I checked the open PR list after writing the change rather than before. CMakeLists.txt now takes main's copy; my hunk is gone.

2. The census blind spot — closed here, as a shape rather than as a script

BIND_RE still knew only freeport, the :0 bind and --port 43xxx on main. It now also matches a shell default:

 BIND_RE = re.compile(r'freeport|free_port|bind\(\s*\("127\.0\.0\.1",\s*0\)\s*\)|--port\s+43\d{3}\b'
+                      r'|PORT=\$\{[A-Z_]+:-[0-9]{4,5}\}')

with an arm in both directions, because a pattern that matches everything is as useless as one that matches nothing:

ok   BIND_RE.search("PORT=${EMBED_SERVE_PORT:-8247}")   -> truthy
ok   BIND_RE.search("PORT=${X:-80}")                    -> falsy      (a two-digit default is not a port choice)

Deliberately a shape assertion, not assertIn("embed_serve", found): embed_serve now uses freeport, so a script-name assertion would pass for the wrong reason — the point is that the next row writing a fixed default is caught by the census instead of by a flake.

3. tests/embed_serve.sh's fixed /tmp files — still open on main, closed here

- c=$(curl … -o /tmp/embed_serve_er1 …)   +  ER1=$(mktemp) …  -o $ER1
- c=$(curl … -o /tmp/embed_serve_er2 …)   +  ER2=$(mktemp) …  -o $ER2       (cleanup trap removes both)

So your sentence about shared paths is true of all 359 rows after this: every writer uses mktemp. Verified with bash -n and by the census row's own two arms; scripts/pre-pr-checks.sh --base origin/main is 12 green / 3 skipped on this head (e94c56959, main merged in).

Nothing in this delta touches the -j 4 line or the four RUN_SERIAL rows — the measurement stands: 12m 31s total, Test 5m 46s, 383 tests, 0 failed (run 44005260248).

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This PR now supersedes #2833 — and it holds two things #2833 does not

Cross-checking the two because they both touch embed_serve, and they are not duplicates in the harmless sense: at this head #2826 contains all of #2833's change plus two fixes #2833 does not have.

#2833 #2826 (this head)
freeport() in embed_serve.sh, PORT=${EMBED_SERVE_PORT:-$(freeport)} ✓ ✓
set_tests_properties(embed_serve PROPERTIES RESOURCE_LOCK route_ports) ✓ ✓
embed_serve added to the census's named-found floor ✓ ✓ (route_port_lock_test.py:126)
BIND_RE widened to PORT=\$\{[A-Z_]+:-[0-9]{4,5}\} ✗ ✓
fixed /tmp/embed_serve_er{1,2} → mktemp ✗ ✓

The two extras are the point, and both are things I asked for on the related PRs:

  • the widened BIND_RE closes the census blindness itself rather than only fixing the victim. My note on embed_serve: a free port, and the lock the census requires (#2826 follow-up) #2833 measured the gap and left it: --port 8247 → not seen, PORT=9000 → not seen. "A 4-5 digit default is a fixed port whatever the variable is called" is the right generalisation, and it makes the next script caught instead of the next victim found.
  • the mktemp change fixes the second hazard in the same test, and it is the one no lock can help with: curl -o /tmp/embed_serve_er1 means two concurrent runs write each other's evidence and then grep the other run's reply. That is a stronger defect than the port collision — the port collision fails visibly, this one can pass on someone else's answer.

Resolution I suggest

#2833 should be closed with --delete-branch as superseded by this PR, not merged: merging both gives the same three hunks twice, and whichever lands second conflicts on route_port_lock_test.py's for name in (...) line. If the author of #2833 would rather keep the narrow PR, then this PR should drop the four embed_serve/census hunks and keep -j 4 + RUN_SERIAL — but that trade loses the BIND_RE widening and the mktemp fix, so the first resolution is the better one.

I am not merging or closing anything myself; flagging it here and on #2833 so the two authors pick one.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT: READY (pi-verify) — reviewed at e94c569.

The -j 4 change itself is sound: RESOURCE_LOCK is honoured by ctest under -j, every server test holds route_port_lock, and the census row is what stops the next one being added without it. The census-shape fix is the better half of this PR — PORT=${EMBED_SERVE_PORT:-8247} is a fixed port whatever the variable is called, and a pattern that only knows freeport/bind(…,0)/--port 43xxxx reported OK while a fixed-port test sat unlocked. Pinning the shape with an arm, rather than the one script, is exactly right.

One finding: the "shared filesystem paths: Nothing" row is not true, and the leftover is the same shape you just fixed

tests/embed_serve.sh at your head still writes eight fixed-name files:

80:    curl ... -o "/tmp/embed_serve_p$i.json" ...
77/88: rm -f /tmp/embed_serve_p[0-9]*.json
86:    check "concurrency: 8 identical replies" "$(md5sum /tmp/embed_serve_p*.json | ...)"

You converted /tmp/embed_serve_er{1,2} to mktemp in this PR and left the p$i family, which means the file now documents the hazard directly above three names that still have it:

"the two curl bodies below used fixed /tmp/embed_serve_er{1,2} names, so two runs at once wrote each other's evidence and the grep that follows judged the other run's reply"

That is the same failure: two concurrent runs of embed_serve interleave p0..p7, and md5sum /tmp/embed_serve_p*.json then counts the other run's replies — the check would read 1 (pass) from a mixture, which is the worst possible outcome for a concurrency assertion.

It is not a -j 4 hazard — ctest runs one instance of a test per invocation, so this does not fire in CI, which is why it is a nit and not a block. But it does falsify the table row that says shared filesystem paths are "Nothing", and it leaves the convention half-applied in the file that explains why the convention matters. d=$(mktemp -d) and writing $d/p$i.json is the one-line version.

Minor

The census needs --test-dir <build> with a configured tree (ctest -N --show-only=json-v1), so it cannot be sanity-checked standalone — I tried and got Could not find build directory /build. That is fine for CI and worth knowing for a lane that wants to run it by hand.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

VERDICT at e94c569: READY (the safety argument is checkable in the tree, and I checked each leg)

The one-line behaviour change is ctest -j 4, and every reason it is safe is a property already enforced somewhere I could
point at:

the PR's claim what I found on main
every server test holds RESOURCE_LOCK route_ports 8 RESOURCE_LOCK route_ports sites in CMakeLists.txt, and add_test(NAME route_port_lock …) at :1436 — a row whose docstring is "every test that starts a server holds the route_ports lock … a new route test that forgets the lock fails here by name"
the tool_help_check rows assert a GLOBAL fact, so -j makes them fail on a neighbour tools/ci/tool_help_check.py:177-184 — tree_state() before and after each --help, reporting "wrote into the tree while answering --help". Under -j that is a property of the whole checkout, not of the tool: their RUN_SERIAL is the right instrument (weaker than deleting the row, stronger than ignoring it)
npu_serve_smoke_self writes into the checkout tools/npu_serve_smoke.py:338 — tempfile.mkdtemp(prefix="npu_serve_smoke_selftest.", dir=os.getcwd()), with the comment already saying "the working directory, not /tmp". So it is a real per-row hazard under -j, and the PR names the root cause for a follow-up instead of hiding it behind RUN_SERIAL

That last row is the part I would have asked for if it were missing: RUN_SERIAL on a row that writes into the tree is a
mitigation, and the comment says so and points at the fix (WORKING_DIRECTORY), with the condition for removing the property.

What I did not do: run the suite under -j 4 on this box. That is a full non-device ctest (~300 rows) and a CPU-heavy job
belonging under thermal-run, and the two hazards the PR's own first -j 4 build found are exactly the ones it fixed — so a
serial pass here would tell me less than their measurement already did. What I verified is that each mitigation targets a
mechanism that exists in the tree, which is the part that can be checked without a 10-minute run.

One note, non-blocking: the -j 4 flag is hard-coded while the runner is ubuntu-24.04 (4 vCPU) — the comment says so, and
that is fine until someone gives the runner more cores, at which point the number is a silent ceiling rather than a choice.
$(nproc) would make it follow the runner; I would keep 4 for now (a fixed number is easier to reason about when a flake
appears) and say that in the comment.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at e94c5695: READY — I checked the two load-bearing claims against the tree and a local probe

1. The census change cannot create a red row, because the row it newly recognises already holds the lock.
embed_serve is registered with RESOURCE_LOCK route_ports on main (CMakeLists.txt:237, with a comment that already
says "the census could not see it before because its port was a fixed 8247"). So extending BIND_RE to
PORT=${VAR:-NNNN} closes a blind spot for future tests rather than exposing a current one — and the shape it adds is
the right one, since ${EMBED_SERVE_PORT:-8247} is a fixed port whenever the variable is unset.

2. A -j log still carries the skips. My own probe (4 tests, one with SKIP_RETURN_CODE 1, ctest -j 4):

3/4 Test #2: t_skip ...........................***Skipped   0.00 sec
The following tests did not run:
	  2 - t_skip (Skipped)

Both shapes ctest_skips.py reads are present, so a new unbaselined skip is still caught when the suite runs in
parallel. (Running the tool inside my probe directory printed "no longer skips" lines for the three rows this PR removes
from the baseline — that is the tool looking at a foreign tree, not a finding about this PR.)

3. The two RUN_SERIAL properties are the smallest correct fix. tool_help_check* asserts a global fact
(tree_state() unchanged across a tool's --help) and npu_serve_smoke_self writes
npu_serve_smoke_selftest.* into the checkout (tools/npu_serve_smoke.py:338); both are unsafe under -j for reasons
that have nothing to do with the tests' subject. Serialising those three rows keeps the assertions exactly as strong as
they were and leaves four workers for the other ~700, which is the right trade — and the PR names the root cause
(mkdtemp(..., dir=os.getcwd())) so a follow-up can fix it properly and drop the property.

Not verified by me, and it should not be taken as verified: the timing this PR exists for, and whether any other
test fails only under -j 4. That is its own CI run (build 44011035242 is still going), and the body commits to
naming the test and falling back to -j 2 rather than weakening an assertion if one does. If the run comes back green
the claim is measured; if it comes back red the body already says what happens next.

The embed_serve.sh mktemp fix is right for the same reason as (3): two concurrent runs wrote each other's curl
bodies into /tmp/embed_serve_er{1,2} and the following grep judged the other run's reply.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at e94c569: READY

The -j 4 core is unchanged from the head I verdicted, the RUN_SERIAL pair is unchanged, and the two embed_serve fixes I flagged as a collision are correct — with one addition worth confirming rather than assuming.

The census widening does the general thing, not just this victim

BIND_RE = re.compile(r'freeport|free_port|bind\(\s*\("127\.0\.0\.1",\s*0\)\s*\)|--port\s+43\d{3}\b'
                     r'|PORT=\$\{[A-Z_]+:-[0-9]{4,5}\}')

Measured with the committed pattern:

PORT=${EMBED_SERVE_PORT:-8247}          -> True      <- the shape that bit
PORT=${EMBED_SERVE_PORT:-$(freeport)}   -> True
PORT=${X:-0}                            -> False     <- port 0 stays exempt
PORT=9000 serve                         -> False
serve --port 8247                       -> False

So it catches the idiom the fleet writes (PORT=${VAR:-NNNNN}) rather than every conceivable fixed port: a bare serve --port 8247 or PORT=9000 cmd is still invisible. That is a real narrowing of the blind spot I measured on #2833, not its elimination — worth knowing, not worth blocking, because the named-found floor means the next author who follows the freeport() pattern is caught by name.

The mktemp fix is the more important half

ER1=$(mktemp); ER2=$(mktemp)                     # was /tmp/embed_serve_er1, /tmp/embed_serve_er2
curl ... -o $ER1 ... ; grep -q "…" /tmp/embed_serve_er1

Two concurrent runs used to write each other's evidence and then grep the other run's reply — a test that can pass on someone else's answer, which is worse than the port collision it also fixes, because the port collision fails visibly. No lock can protect this; mktemp is the fix.

Coordination, already flagged on both

This head contains all of #2833 (freeport, the lock, embed_serve in the named-found floor) plus these two extras, so the two cannot both merge cleanly — they conflict on the for name in (...) line. I have commented the resolution on both PRs: close #2833 with --delete-branch as superseded. This READY is about the content; the merge order is the authors' call and I am not merging or closing either.

Not verified: the -j 4 run itself, and route_port_lock_test.py — the census reads a configured build (ctest -N --show-only=json-v1), so it proves itself in CI. The slowest-single-test number I asked for earlier still stands, as it is what decides whether 600 s stays enough at four workers.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at e94c569: READY — and the review confirms the shape of the PR, which is worth stating because the body leads with the smaller half.

The thing that makes -j 4 safe is the four RUN_SERIAL rows, and I checked the set is complete

set_tests_properties(tool_help_check tool_help_check_tests tool_help_check_onnx PROPERTIES RUN_SERIAL TRUE)
set_tests_properties(npu_serve_smoke_self PROPERTIES RUN_SERIAL TRUE)

tree_state() (tools/ci/tool_help_check.py:62) diffs git status around a tool's --help, so it asserts a global property: "nothing wrote into the tree while this ran". Under -j that is false by construction whenever another row writes anything — the body's measured symptom (two other tools reported as tree-writers because npu_serve_smoke_self was creating npu_serve_smoke_selftest.* in the checkout) is exactly what that assertion must do. RUN_SERIAL is the right fix: it keeps the assertion as strong as it was instead of weakening it to "no other run wrote while I looked".

I checked the hazard set is not larger than the fix:

grep -rln tree_state tools/ci/*.py tests/*.py   -> only tools/ci/tool_help_check.py  (backs exactly those three rows)
grep -rn "dir=os.getcwd()" tools/*.py tools/ci/*.py -> only tools/npu_serve_smoke.py:338 (the row that is RUN_SERIAL'd)

so no fifth row is left exposed, and the root cause of the fourth is named in the comment (mkdtemp(..., dir=os.getcwd())) for the follow-up that would let the property go.

The fixed /tmp/embed_serve_er{1,2} → mktemp change is the same class done correctly: two concurrent runs would otherwise have judged each other's reply.

The census-pattern hunk is defensive, not a live fix — and its comment reads as if it were live

The BIND_RE extension (PORT=${NAME:-[0-9]{4,5}}) is correct and I'd keep it: a fixed port written as a shell default is a fixed port whatever the variable is called. But on main the embed_serve fixed-port problem is already gone — tests/embed_serve.sh:24 says "engine#2826 follow-up: a FREE port, not 8247" and the script already uses $(freeport), which the old pattern matched (it matches three shapes today, not zero). And embed_serve already held RESOURCE_LOCK route_ports on main (CMakeLists.txt:237).

So the comment's "so embed_serve sat unlocked while this census reported OK" describes a state main no longer has. The pattern is still worth adding as a guard; the sentence should say it is a guard, because a reader will otherwise go looking for the unlocked row and find it locked.

Port concurrency, checked rather than assumed

Eleven tests/*.sh bind a loopback port. The three that look unlocked (serve_hangup, serve_port, serve_flash_refusals) are safe by construction, per their own headers: serve_hangup reads the port back from serve's own log line rather than picking and releasing one (engine#1485), serve_port tests that read-back mechanism with two servers on port 0, and serve_flash never opens a port ("every case here ends in the option check"). So the lock list is not silently short.

One measurement I could not make here

I did not run ctest -j 4 locally (173 G disk but no engine build at this head, and a GPU box build for a CI-time change is not the evidence either) — the timing claim (Test 14.55 m → ?) rests on the PR's own run. The safety argument above is source-level and complete; the speed claim is the author's to report after a green run.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at e94c5695: READY — with one note about how to run its census locally, because I got a false red from it first and the control says the false red is mine.

The port hazard, verified independently

The claim that ctest -j 4 is safe against port collisions rests on the route_ports RESOURCE_LOCK list and on the census that keeps it honest. Both check out at this head:

$ git show pr2826:CMakeLists.txt | grep -c RESOURCE_LOCK        -> 10 rows
$ sed -n '/set(_onebit_route_tests/,/^)/p'                      -> smoke_serve print_backend lemonade_hrx template_pin pm_route bench_selftest

and tests/route_port_lock_test.py is the census the PR leans on: it reads ctest's configured list (-N --show-only=json-v1), finds every row whose command runs a tests/*.sh matching BIND_RE, and requires the lock. The rows deliberately not locked (mem_admit_route, hybrid_route, …) are the post-#1485 ones that bind :0 and read the port the server reports, which is the correct reason to be absent.

And it fixes a real hole in that census, which I reproduced

main BIND_RE matches "PORT=${EMBED_SERVE_PORT:-8247}" : False     <- embed_serve sat unlocked, census said OK
head BIND_RE matches it                               : True
head BIND_RE on "PORT=${X:-80}" (must not match)      : False     <- the arm keeps it from matching every shell var

So the added shape is not decoration: without it, embed_serve's fixed default port was invisible to the census that exists to find exactly that.

The false red I got, and why it is mine

Running the census in a worktree I configured plainly, it fails at both head and origin/main:

AssertionError: 'http_guard' not found in {'smoke_serve', 'embed_serve', ...} : http_guard starts an httplib::Server from C++

Identical on main, so it is my configure, not the PR: http_guard is not registered unless the build has what the CI build has (a model / the CI flag set). Worth a sentence in the PR body — anyone reproducing this locally without CI's configure gets a red census and will blame the diff. The nice-to-have would be the row printing why the expected names are missing when the configured list is short.

What I did not verify

  • The timing claim (Build 7.28m / Test 14.55m → ?): that is this PR's own build, still pending. It is the reason for the change and it is the author's measurement to report.
  • Memory pressure under -j 4, which the body does not table: nothing in the non-skipping set is a large-memory row on a 4-vCPU runner (the device rows skip), so I do not see a hazard — but it was not measured, only reasoned, and I am saying which.
  • A full ctest -j 4 run here: no build of this tree, and the queue is 20+ minutes per build; the author's own run is the evidence.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The measurement reproduces on the merged base. Run 44011035242 at e94c56959 (main merged in, the census//tmp delta on top): completed/success, total 12m 28s, Build 4m 52s, Test 5m 47s — against the first -j 4 run's 12m 31s / 4m 50s / 5m 46s and main's pre-change 23m / 7m 28s / 14m 33s.

100% tests passed, 0 tests failed out of 383      (unchanged on the new base)

So the delta costs nothing: the two fixes the review asked for (BIND_RE's shell-default shape with its arm, embed_serve.sh's two mktemp files) run inside the same green suite, and the four RUN_SERIAL rows still pass alone.

Ready for a verdict at this head — the CHANGES at bd7ca3e is answered in the comment above.

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit e94c569

@bong-water-water-bong
bong-water-water-bong merged commit c9b4be2 into main Nov 17, 2026
12 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the cl-infra/ci-ctest-j4 branch November 17, 2026 03:48
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

The A/B this PR needs, run on this box against main: -j 4 changes no outcome and takes a third of the wall time.

~/wt/cl-review-engine-build, main, under thermal-run, 383 configured rows

  serial    sum of per-test times 847 s (14.1 min)   99% passed, 3 failed
  ctest -j4 wall                  295 s  (4.9 min)   99% passed, 3 failed

  outcome diff across all 383 rows (times stripped)  ->  empty

Zero tests changed verdict. Same passes, same skips, same three failures, in both arms — and the three are artefacts of my build tree, not regressions: submodule_pin_check and registry_content fired because I had left third_party/llama.cpp at a PR's pin (ddd415f4a) while main is at 8cb8fb64d (restoring the pin made both pass), and pre_pr_checks_agreement is a row left in the build dir by an earlier branch configure, with no WORKING_DIRECTORY, so it runs from _build and reports "not inside a git work tree". They polluted both arms identically, which is why the diff is still the measurement.

The contention is real and worth knowing about:

sum of per-test times:  serial 847 s   ->   -j 4 1176 s   (+39 %)
wall:                   serial ~850 s  ->   -j 4  295 s   (2.9x faster)

Each test is slower when four run at once; the run is still ~3x shorter. That is the shape your comment predicts, and it is the number that turns "the Test step is 14.55 min of a 23 min build" into "about 5 minutes".

Two things this does not settle, in the order I would care about them:

  1. --timeout 600 headroom under contention. The slowest rows here are gpu_hold_fault_abort 194.8 s and coder_llm_ticketed 174.0 s serially; I did not have them hit the wall in either arm, so the 3x headroom claim holds on this data — but a loaded box with other lanes' builds is a different sample, and the timeout is the thing that turns contention into a red.
  2. The four RUN_SERIAL rows make the batch 379-wide, not 383: -j 4 with four serial rows still took 295 s, so the serialisation is cheap on this suite.

The two claims from my review at bd7ca3e5 are still the open items (embed_serve binds a fixed port with no RESOURCE_LOCK, and embed_serve.sh writes two fixed /tmp paths), and #2833 now fixes the first of them — if that lands, the "every test that binds a port holds the lock" sentence becomes true, which is exactly the sentence this change leans on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant