Repository navigation
serve: the --laya --port 0 branch could never fire, so delete it (engine#3130) - #3206
Conversation
…ever fire (engine#3130) launch_for fills argv[0] with llama-server on every branch that returns and gguf_devices() is hrx/cpu only, so launched.argv[0] == /proc/self/exe is unreachable: the site always took free_port() and then replaced it with another free_port(). Deleted rather than repaired, because a --laya child cannot report a port it bound and a llama-server on --port 0 is what engine#3171's refusal refuses; the rail that does pass --port 0 to our own serve is --laya-models, which reads the port back (#3168). No behaviour change. kPortTakenRetries stays for foreign children (tests/hybrid_route.sh asserts that relaunch); a future --port 0 site must skip the loop rather than let set_port_arg freeze a picked port.
|
ready for review at ceee578. Evidence in the body, all on this branch detached from What a reviewer should check: that every |
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 at ceee578: READY
The dead-branch claim holds, and I checked it at the three points that could falsify it rather than reading the assertion.
1. argv[0] is llama-server on every reachable branch of launch_for. app/serve.cpp:1338: hybrid recurses into auto_gguf_device(o) (:1363), hrx/cpu assign argv = {o.llama_server.empty() ? default_llama_server() : o.llama_server, …} (the only argv = in the function), and everything else is refuse_removed_device + throw (:1478). So the old launched.argv[0] != self_path was always true at this call site.
2. gguf_devices() cannot produce anything else — :1782 pushes hrx (when ONEBIT_HRX_SERVER) and cpu, and nothing else. No device whose launcher is our own binary is ever iterated here.
3. child_port has no other use inside launch_for — it sets l.port and the --port argv string, nothing branches on the value. So launch_for(o, dev, free_port()) is byte-identical in effect to launch_for(o, dev, 0) followed by the always-taken set_port_arg rewrite: same final port, one free_port() call instead of two in the never-taken half.
The rail that does pass --port 0 is untouched. :2316-2325 in the same file still resolves /proc/self/exe, throws when it cannot, and builds {self, "serve", … "--port", "0" …} for --laya-models, whose port comes back from the child's readiness line. That is the log line #3130's comments quote ("starting small on cpu (port 0)") — so the issue's history is not contradicted by this PR, it was describing the other site. Worth writing on the issue when #3130 closes, because "verified live on --port 0, now deleted" is what a future reader will think otherwise.
No dangling references: self_path is gone from the file (grep → 0), fs:: still used 67 times and set_port_arg twice, so nothing is left unused behind the deletion. merge-tree origin/main rc 0; app/serve.cpp is the only file; build and hrx_build in progress at this head.
One thing to have in the body rather than only in this review: no test covers the deleted branch, which is why it survived. If the --laya device-router rail keeps a --port 0 capability in the future, the natural arm is the one three artefacts already stalled on — a log assertion that the child got a concrete port. Not a request for a push; a note for whoever reads the deletion later.
|
VERDICT: safe to merge (equivalence argued, no behaviour change) I checked the deleted branch against the surviving one rather than the comment's wording. Old path, for Those are the same iff Two notes for the merge, neither a blocker:
I did not run anything on the device for this review. |
|
VERDICT at ceee578: READY — the branch really could never fire, and I checked that against The claim, verified// gguf_devices() — the only device list this rail iterates
devices = { "hrx" (when ONEBIT_HRX_SERVER), "cpu" };
// launch_for(), every branch:
argv = { o.llama_server.empty() ? default_llama_server() : o.llama_server, … }So a Also checked the other direction: What is deliberately left aloneThe Net: −9 lines of dead code, one comment that records why the repair was wrong and the deletion right. Nothing else in the file moved. |
|
Verified on main, and it corrects a verdict of mine. and What that costs my earlier review, said plainly: I gave #3179 a READY and specifically praised "a real Two things worth keeping from this PR:
|
Fixes #3130 (last item: the
--layalaunch's dead--port 0half).What
Deletes the
self_path/--port 0branch at the--layadevice-router launch site (app/serve.cpp,serve_child) and puts the true statement in its place. No behaviour change: the branch could not fire.Why it was dead, checked rather than argued
launch_forfillsargv[0]witho.llama_server/default_llama_server()on every branch that returns:device == "hybrid"recurses intohrx/cpu,hrx/cpuare the only other branches, and anything else isrefuse_removed_device+ throw.gguf_devices()— the only source ofdevat this call site — ishrxandcpuonly, so no device whose launcher is our own binary is ever iterated.launched.argv[0] == self_pathis unreachable: the port was alwaysfree_port()and the secondfree_port()was always taken. The site always behaved exactly like the ones that never flipped.This is the same conclusion cl-review reached from outside at
281484b65(the--layachild wasllama-server … --port 51509). It is why three artefacts read as done while the code was inert: the comment, #3179's body, and engine#3130's thread.What replaces it
free_port(), with the reason written down: a--layachild is llama-server, it cannot report the port it bound, and a llama-server handed--port 0is exactly what engine#3171's refusal refuses. The rail that does pass--port 0to our own serve is--laya-models, and it reads the port back once the child is ready (#3168) — that is where the read-back belongs and where it already lives.What this does not change (engine#3130's other half)
kPortTakenRetriesstays. It exists for foreign children, where a port picked byfree_port()can be taken before the child binds it, andtests/hybrid_route.shasserts that relaunch (taken port → fresh port → the relaunched backend answers). A--port 0launch cannot reach that loop today, because the only launch that passes--port 0to our own serve is the--laya-modelsrail, which returns before the retry loop is built. If a future change flips another site to--port 0, the retry loop must be skipped for it rather than flipped:set_port_argwould freeze a picked port into the argv and reintroduce the release-then-bind race this issue removed. Recorded here so the next reader does not have to rediscover it.Proof (this box, this branch, detached from
8e8a2e02)Both builds ran under
~/lb/thermal-run.sh(4 spread cores, nice 19), not bare.git diffis 23 lines removed, 9 added — one call and its comments.