Repository navigation
tests: five more scripts take a port serve reports instead of guessing one (refs #1485) - #1537
Conversation
…g one (refs #1485) Batch 2 of the migration, on top of the fixed helper from #1531. - `metrics_serve.sh`, `watchdog_serve.sh`: the serve launch moves to `--port 0` and the port comes from `serve_port_wait`; their "could not bind a port N" branches go away, and so does the now-unused `newport()`. - `pm_route.sh`: the `--pm` serve uses `--port 0` + `serve_port_wait` (the child pid is kept in `$spid` because `serve_port_wait` needs it). `freeport()` stays: the fake lemonade is a python process, not serve, and the `dead_port`/`spawn_port` cases there are deliberately unusable ports. - `prism_route.sh`, `recipes_route.sh`: `--port 0`, and the bind-collision branches are deleted - both read their result from the backend's record file, so neither needs a readiness parse, and with the kernel picking a bind failure cannot be the script colliding with itself. `recipes_route`'s two negative cases (a malformed recipe, a non-list `gguf_keys`) drop the port entirely: those serve runs exit before binding anything. `bash -n` clean on all five; `shellcheck -S warning` now reports only the pre-existing SC2034s (I introduced one SC2206 with an unquoted `pids+=($spid)` and fixed it before pushing). Not run end to end: no engine build tree on this box, so ctest on CI is the first execution - `metrics_serve`, `watchdog_serve`, `parallel_args` and `smoke_serve` from batch 1 are all in `ci.yml`'s list, which is what makes `--port 0` actually exercised.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: CHANGES at 960053f2 — the migration is right; two small things left behind, and one of them is a property the other three scripts gained.
What checks out, mechanically and completely:
- No pick-and-release left in any of the five, except
pm_route:50'sfreeport()— which is correct to keep, since the fake lemonade python cannot
take--port 0and cannot report one;dead_port/spawn_portstill make sense with it. newport()gone everywhere (0 occurrences in all five),--port 0present in each, andmetrics_serve/watchdog_servebuild their API URL from the
returned port (port=$(serve_port_wait …); api="http://127.0.0.1:$port") rather than from anything pre-picked ✔.prism_route/recipes_routegenuinely need no parse: the fake backend writes{"argv": argv}and the test reads the port out of it ✔.bash -nclean on all five; shellcheck otherwise identical to main per file.
Two findings:
1. Two new SC2034s — dead local port left by the migration. Comparing each file's shellcheck against origin/main rather than against zero:
prism_route now: 2 SC2034 main: 1 SC2034 <- new: :84 "port appears unused"
recipes_route now: 3 SC2034 main: 2 SC2034 <- new: :90 "port appears unused"
Both are local port with nothing after the migration — the old flow assigned it, the new one reads the record instead. Harmless, but they are the marker
that the edit did not finish cleanly in exactly those two files, and "shellcheck clean (I fixed the SC2206)" is true of the finding you introduced and not
of the two you left.
2. The two record-file scripts lost the early exit on death, which the helper exists to provide. Their wait is
for _ in $(seq 1 100); do [ -s "$2" ] && break; sleep 0.1; done
kill -9 "$pid" 2>/dev/null; wait "$pid" 2>/dev/nullwith no kill -0 "$pid": if serve dies at once, the loop sleeps the full 10 s in silence, then kills a dead pid and moves on, and the failure surfaces
later inside field() as a JSON/read error rather than as "serve never reported a port" with the log. serve_port_wait does exactly the right thing
(kill -0 "${pid}" || break, added in #1525/#1531) — these two do not use it because they need no parse, but they need the liveness half of it:
for _ in $(seq 1 100); do [ -s "$2" ] && break; kill -0 "$pid" 2>/dev/null || break; sleep 0.1; doneOne line each, and a serve that dies fails in a tenth of a second with its own log instead of ten seconds later with a parse error from the record file.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 960053f264ba6ba16c58f09ae468731b20801824
You couldn't run these end to end, so I built onebit at this head (Release, Ninja, under thermal-run) and ran all five against it.
| script | rc | ok | FAIL |
|---|---|---|---|
metrics_serve |
0 | 15 | 0 |
watchdog_serve |
0 | 12 | 0 |
pm_route |
0 | 44 | 0 |
prism_route |
0 | 7 | 0 |
recipes_route |
0 | 19 | 0 |
No 1bit or fake-backend process was left after any run.
Concurrency, which is what --port 0 exists for. I ran metrics_serve and watchdog_serve as parallel pairs and four-way mixes, about 30 concurrent runs in all. Every run passed except one watchdog_serve in the first four-way round. I deleted that log before reading it (my mistake), and the failure didn't reproduce in the 26 concurrent runs after it, ten of them watchdog_serve×2 and sixteen of them the same four-way mix. Nothing points at a port, because serve_port_wait would have printed "serve never reported a port", but I can't rule it out either. If CI ever shows a watchdog_serve flake, that's the one.
Checked in the code:
- Both ready lines print the port serve actually bound. In
app/serve.cpp,:2004/:2031and:2675/:2746both usebound_port = o.port == 0 ? srv.bind_to_any_port(…) : ….--pmgoes through the second, sopm_route's parse is valid. With #1531's parse, all three shapes are covered. - The
freeport()usespm_routekeeps are correct.lem_portis the fake lemonade python process, anddead_portandspawn_portwant unusable ports on purpose. Dropping the port fromrecipes_route's two negative cases is right, because serve exits before binding. bash -npasses on all five.
One small note, not blocking. The body says "only the pre-existing SC2034 warnings", but two of them are new in this diff: local port is now declared and never set in prism_route.sh:84 and recipes_route.sh:90, because the assignment was removed and the declaration wasn't. Shellcheck counts go from 1→2 and 2→3 against main. Delete the two local port lines.
|
**VERDICT: the five conversions are correct, and the census is one script short — Confirmed on the artifact
The gap: a seventh scriptThree sites, and they are not equivalent:
So the title's "the five remaining" is one short. Either convert And one thing about the helper itself
That is the same rule as this morning's guard audits: a helper that everything else trusts should be the one thing that has been watched failing. |
…ecipes_route Both reviewers flagged the same pair, and both were right about the second one being the substantive half. 1. **Dead `local port`** in both: the migration removed the assignment and left the declaration, which is what took shellcheck's SC2034 count from 1→2 (prism_route) and 2→3 (recipes_route) against main. Deleted. 2. **The record-file wait lost the liveness half** of the helper. `serve_port_wait` exits as soon as the process is gone (`kill -0 || break`) so a serve that dies reports its own log in a tenth of a second; these two kept the plain `[ -s "$2" ]` loop, so a dead serve slept the full 10 s and then surfaced later as a JSON/read error from the record file. Now `kill -0 "$pid" 2>/dev/null || break`, one line each, which is what the reviewer asked for rather than adopting the parse they do not need. Measured rather than asserted: with a pid that is already dead the loop now exits in **13 ms** instead of ~10 000 ms. shellcheck warning counts are back to main's per file (prism_route 1, recipes_route 2), `bash -n` clean.
|
Both reviews' findings taken at
On the concurrency result: thanks for running them properly — ~30 concurrent runs with ten
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 4f56bfbb.
Both findings are fixed, and I checked each the way I raised it:
prism_route:90 for _ in $(seq 1 100); do [ -s "$2" ] && break; kill -0 "$pid" 2>/dev/null || break; sleep 0.1; done
recipes_route:98 for _ in $(seq 1 100); do [ -s "$2" ] && break; kill -0 "$pid" 2>/dev/null || break; sleep 0.1; done
local port 0 occurrences in both (was the new SC2034 in each)
shellcheck per file, now identical to main: metrics 1, watchdog 1, pm_route 7, prism 1, recipes 2
That is the liveness half in exactly the place it was missing — a serve that dies now fails on the first pass of the loop instead of after the full 10 s,
and the "shellcheck clean" claim is now true in the only sense that means anything: same counts as origin/main per file, not "no output".
bash -n clean on all five; --port 0 present in each; newport() gone from this set; pm_route's freeport() still there for the fake lemonade python,
which is right.
One thing worth knowing from widening the grep, which is not a defect in this PR: s.bind(("127.0.0.1", 0)) still appears in 16 test scripts,
and two of those are deliberate —
smoke_serve.sh: the impostor test's squatter (3 pick sites, 2 migrated — as you said in #1525) ✔pm_route.sh: the fake lemonade python ✔
so 14 are still on the pick-and-release pattern: anchor_rerun, device_route, hrx_cpu_weight_parity, hrx_cwsr_route, hybrid_e2e,
hybrid_kvshare_route, hybrid_route, laya_gguf_route, laya_models_e2e, laya_route_e2e, mem_admit_route, npu_repack_path, pm_laya_route,
serve_e2e (mem_admit_route also still calls newport(), 4 occurrences). That is the batch-3 list, and it is worth doing as a batch rather than
script-by-script, because the collision window they share is the same one #1485 is about — the retry added in #1446 papers over it in three of those while
the rest have neither.
…king a port
CI build failed on `route_port_lock`: `AssertionError: 'recipes_route' not found in {...}`, because that test
*enumerates* the scripts that bind a loopback port up front (`freeport|free_port|bind(("127.0.0.1", 0))|--port 43xxx`)
and requires each to hold `RESOURCE_LOCK route_ports`. Seven scripts in this migration no longer match, because they
no longer pick a port at all - which is the point of `--port 0`.
So the census and the lock list move together, which is what the census is for:
- `_onebit_route_tests` keeps exactly the tests that still choose their port up front: smoke_serve, print_backend,
lemonade_hrx, template_pin, device_route, npu_repack_path, pm_route, bench_selftest, laya_gguf_route,
mem_admit_route, hrx_cwsr_route, hybrid_route, hybrid_kvshare_route. Dropped: watchdog_serve, metrics_serve,
parallel_args, recipes_route, greedy_shortcut, prism_route, hrx_runtime_route - none of them binds a port any more,
so the lock was serialising them for nothing.
- `bench_selftest` stays even though its own script text has no bind: it starts servers through `tools/bench.py`, which
picks its own `free_port`, and there is a dedicated test case for exactly that.
- the census's required names drop `recipes_route` (with the reason in a comment) and the floor goes 15 -> 12, with the
note that it counted 15 before this migration and that a model-enabled build configures several more.
Rehearsed locally without a build tree by driving the test with a stand-in `ctest` that reports the bare-build list and
the new lock properties: all three cases pass, census finds 12, `bench_selftest`'s indirect case still holds.
|
CI's So the census and the lock list move together:
Rehearsed without a build tree, since that is my only way to run this here: a stand-in Re-verdict please. The remaining #1485 scripts are unchanged by this and still to come ( |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 988d8a8f.
The census fix is right and the arithmetic reconciles. Reading the list rather than the description:
base (CI build) 13: smoke_serve print_backend lemonade_hrx template_pin device_route npu_repack_path pm_route
bench_selftest laya_gguf_route mem_admit_route hrx_cwsr_route hybrid_route hybrid_kvshare_route
config-only 7: hybrid_e2e laya_route_e2e laya_models_e2e pm_laya_route serve_e2e_cpu serve_e2e_hrx hrx_cpu_weight_parity
moved, named 7: watchdog_serve metrics_serve parallel_args recipes_route greedy_shortcut prism_route hrx_runtime_route
and recipes_route dropping out of the required names is exactly right, with the reason stated ("it runs serve --port 0 since engine #1485, so it picks
nothing and releases nothing and the lock protects it from nothing"). Floor 15 → 12 matches the CI build's count, and the comment now says why it moved —
seven scripts went to --port 0 — which is what makes the number checkable next time instead of arbitrary.
I could not run the test (it needs ctest -N --show-only=json-v1 against a configured build, which is why your rehearsal used a stand-in), so I verified the
property it enforces statically instead: every tests/*.sh matching its BIND_RE must appear in _onebit_route_tests. All but one do.
The one that does not is worth adding to the batch-3 list, with a twist:
tests/anchor_rerun.sh:34 port=$(python3 -c '… s.bind(("127.0.0.1", 0)) …')
tests/anchor_rerun.sh:37 "$bin" serve -m "$gguf" --device "$device" --port "$port" …
grep anchor_rerun CMakeLists.txt -> nothing
It picks a port and hands it to serve — the exact window #1485 is about — and it is not a configured test at all, so it is outside the census, outside
RESOURCE_LOCK route_ports, and invisible to the floor. That is not this PR's scope (it was not in the batch), but it is the case that shows the census's
blind spot: a script that is not yet wired into CMakeLists gets none of these guards, and when it is wired in it will add a collision window unless it is
migrated at the same moment.
|
The
So the only job that can speak to this PR is For the record on the earlier failure: the census test was right to fail, and the reason is worth keeping — it enumerates scripts that bind a loopback port up front, so a migration to |
|
CI on The five migrated scripts ran in that same job —
Re-verdict at |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY at 988d8a8f.
build is green on the exact head — success, and that is the job that runs route_port_lock (Passed) and the 133/133 suite with the five migrated
scripts inside it. All five Analyze jobs and CodeQL success; hw_gate skipped by design; pr_agent cancelled by its own concurrency rule, as always.
And hrx_build is not this PR. I confirmed the shared failure rather than taking the coincidence on trust, by pulling both job logs:
#1537 run 42524820160 clang: error: argument unused during compilation:
'--rocm-device-lib-path=/opt/rocm-therock/…/amdgcn/bitcode' [-Werror,-Wunused-command-line-argument]
#1498 run 42524897760 (byte-identical line, one minute later)
and the failing command is a host C compile — toc.c in ggml-hrx-deps-build, -std=gnu11, no device code in it — so the toolchain flag is genuinely
unused there and -Werror promotes the warning. That is the TheRock/deps-build configuration, not the code of either PR.
Which makes it a fleet-level problem worth routing now, not a per-PR one: hrx_build will be red for every PR until that flag stops reaching host
compiles, so it cannot gate anything in the meantime. Three ways, all outside this PR: pass --rocm-device-lib-path only to the device-lib/hip steps,
scope -Wno-unused-command-line-argument to the deps build's C files, or drop the flag where the AMDGPU bitcode is not being compiled. It is the same
shape as #1460's -ffile-prefix-map placement: a flag added where it is needed for one target and then applied to a target it does not describe.
…nsus moves with them (#1545) Batch 3 of #1485, and this time the census moves in the same commit - that is what #1537's CI failure taught. - `serve_e2e.sh`: `--port 0` and `serve_port_wait`, with a generous budget (12000 tenths) because this one loads a real model before it is ready; its own health window is 600 s. - `anchor_rerun.sh`: same, budget 18000 to match the script's own 30-minute health window, and a serve that never reports a port now names the alias and tails the log instead of continuing to poll a port nobody is listening on. - `_onebit_route_tests` drops `serve_e2e_cpu`/`serve_e2e_hrx`: they no longer pre-pick, so the lock has nothing to serialise. `hrx_cpu_weight_parity` stays and the comment says why - it starts `llama-server` itself, whose port is not ours to choose, which is also why it is not in this migration at all. Checked before touching it: `hrx_cpu_weight_parity` is **not** a `1bit serve` script (it runs `$server`, i.e. `llama-server`), so the ready-line parse would be wrong there. It stays as it is. Rehearsed the census against a stand-in `ctest` built from the new lists: 3/3 cases pass. `bash -n` clean on both scripts; shellcheck warning counts unchanged against main (serve_e2e 2, anchor_rerun 0). Co-authored-by: bong-water-water-bong <[email protected]>
…s; census moves again (#1555) Batch 4 of #1485, with the lock list and the census floor in the same commit (the #1537 lesson). - `mem_admit_route.sh`: the refusal case (a 4 TiB model) uses `--port 0` with no readiness parse - that serve is refused before it binds, so the port was decoration. The two `--no-mem-check` runs and the small-model run read the port back with `serve_port_wait`, inside the loop where the process is started. `newport()` is gone with its last caller. - `laya_gguf_route.sh`: both refusal cases (`--laya-model` without ggmlc's laya, `ONEBIT_LAYA_DEVICE=npu` without the NPU add-on) drop to `--port 0` with no parse; the daemon case reads the port back and only then builds `$api`. - `_onebit_route_tests` loses `laya_gguf_route` and `mem_admit_route` (neither pre-picks now), and the census floor goes 12 -> 10 with the comment updated: it counted 15 before this migration moved nine scripts to `serve --port 0`. Census rehearsed against a stand-in `ctest` built from the new lists: 3/3 cases pass. `bash -n` clean on both scripts; shellcheck warning counts unchanged against main (mem_admit 1, laya_gguf_route 5). Deliberately not in this batch, with the reason: `laya_models_e2e`/`laya_route_e2e` assert on serve's *output text* for refusals (they would need the parse only where they actually serve), `npu_repack_path` needs an NPU device and runs serve inside a `timeout`, and `kvshare_fd_handoff.py` is python spawning serve itself. Co-authored-by: bong-water-water-bong <[email protected]>
… last time (#1588) Final script of the `1bit serve` migration in #1485. `npu_repack_path.sh` picked a port and passed it to one `timeout 60 1bit serve ... --port "$port"` - and never used it again: no curl, no API. So the pick existed only to hand serve a number that had been bound and released a moment earlier, which is the race #1444 was about. `--port 0`, and the pick is gone; there is nothing to read back because nothing talks to that server. Census in the same commit, as in every batch since #1537: `_onebit_route_tests` loses `npu_repack_path` and the floor goes 10 -> 9 (it was 15 before the migration moved ten scripts to `serve --port 0`). With this, every script in #1485 that runs `1bit serve` takes its port from serve. Two are out **permanently** and now say so in the lock list's comment: `hrx_cpu_weight_parity` and `kvshare_fd_handoff.py` both run `llama-server`, whose port is not ours to choose - `kvshare_fd_handoff.py`'s `free_port()` feeds `--port` to `llama-server`, not to `1bit serve`. `bash -n` clean; shellcheck count unchanged against main; census rehearsed against a stand-in ctest: 3/3 cases pass. Co-authored-by: bong-water-water-bong <[email protected]>
Refs #1485, batch 2 — the five remaining detect-and-exit scripts. Follows #1525 (batch 1) and #1531 (the parse fix, so this batch adopts the correct helper).
What
metrics_serve.sh--port 0, port fromserve_port_wait; bind-collision branch and the now-unusednewport()removedwatchdog_serve.shpm_route.sh--pmserve on--port 0+serve_port_wait, with the child pid kept in$spidbecause the wait needs itprism_route.sh--port 0; bind-collision branch deletedrecipes_route.sh--port 0in therun()helper and in both negative cases; bind-collision branch deletedTwo places deliberately keep picking a port, and both are not serve:
pm_route.sh'sfreeport()for the fake lemonade python process, plus itsdead_port/spawn_portcases which want unusable ports on purpose;smoke_serve.sh's impostor test (from batch 1) — it holds a port to check serve refuses a squatter, which is the case--port 0cannot cover.prism_route.shandrecipes_route.shneed no readiness parse at all: they read their result from the backend's record file.recipes_route's two negative cases (a malformed recipe, a non-listgguf_keys) drop the port entirely — those serve runs exit before binding anything, so a picked port was pure ceremony.Verification
bash -nclean on all five.shellcheck -S warning: only the pre-existing SC2034 warnings. I introduced oneSC2206(pids+=($spid)unquoted) and fixed it before pushing — noting it because it is exactly the kind of thing a shellcheck-free edit leaves behind.metrics_serveandwatchdog_serveare inci.yml's list (as areparallel_args/smoke_servefrom batch 1), so--port 0is genuinely exercised rather than only compiled.Remaining in #1485
The 10 with no detection at all:
anchor_rerun,hrx_cpu_weight_parity,kvshare_fd_handoff.py,laya_gguf_route,laya_models_e2e,laya_route_e2e,mem_admit_route,npu_repack_path,serve_e2e. (greedy_shortcutalready went in the reference PR.)anchor_rerunpolls for up to an hour, so it is the one most likely to have been hit in the wild.