Repository navigation
Studio listeners and provider URLs: IPv6 loopback, sidecar owners, metadata addresses - #19199
Merged
Merged
Conversation
…ch another listener (cherry picked from commit 73b3091de291be6462895e397f6266aee57ed5af)
… child's listener (cherry picked from commit 9ed0f5f1045c12de626858064ed927ccf113c813)
…IPv6 metadata services (cherry picked from commit bf06defef0d63a3c7860bca75d626207626dfcfe)
…ndpoint and headers (cherry picked from commit 2d1c95b2a6bbaa598061f5ad7ced8e081d86bdb6)
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
rhsCZ
pushed a commit
to rhsCZ/unsloth
that referenced
this pull request
Nov 24, 2026
…s listening (unslothai#19242) ## Problem While a vLLM or SGLang model loads, the Studio readiness loop in `ManagedEngine._start_once` polls every 0.25 s. Since unslothai#19199 every poll first runs `LlamaCppBackend._health_listener_is_ours`, which walks the child process tree with psutil, reads each child's sockets and then scans every inet socket on the host. Until the engine binds its port nothing is listening, so each of those scans is wasted, and on Linux and macOS each one also logs ``` llama-server port N answered /health but our child PID is not listening on it; refusing to use it ``` at error level, for the whole 1 to 5 minute load. Every other caller of the check runs it once, after `/health` has already answered. ## Change Before the ownership check, the poll now makes a plain TCP connection to the same host and port the `/health` probe uses (parsed from `base_url`, so an IPv6 `[::1]` URL connects to `::1`) and sends nothing. - Refused or unreachable: wait 0.25 s and loop, as before. The old path also waited here: the check returned False on Linux and macOS, and on Windows it returned True and the probe then failed to connect to the same address. - Accepted: the unchanged ownership check runs, then the unchanged keyed `/health` probe. Both still run on every iteration, and nothing is cached. Timeouts, stall detection, cancellation, the exited-child path and the Windows ownership rules are untouched. The connect timeout is 2 s, the same as the probe client's. ## Results A fake engine is launched through the real `ManagedEngine.start` path, with the same Popen flags and stdin pipe. It spawns 4 idle workers, prints progress lines for 30 s, then binds 127.0.0.1 and serves `/health`. There were 3 interleaved runs per arm on the same Linux host. The spread across each arm's 3 runs is the A/A noise. | Metric (median of 3, range) | Base | Head | | --- | --- | --- | | Ownership checks per load | 38 (36 to 39) | 1 (1 to 1) | | False "not listening" error lines | 37 (35 to 38) | 0 | | CPU in the ownership check | 20.09 s (20.08 to 20.35) | 0.38 s (0.34 to 0.42) | | Studio process CPU during the load | 20.18 s (20.17 to 20.43) | 0.49 s (0.47 to 0.55) | | Keyed `/health` probes | 1 | 1 | | Ready after engine bind | 0.42 s (0.40 to 0.50) | 0.45 s (0.41 to 0.48) | | Total load time | 30.53 s | 30.56 s | This host has many sockets, so one scan costs about 0.5 s of CPU, which is more than a typical desktop. The call count and the error lines do not depend on the host. ## Tests New `studio/backend/tests/test_managed_engine_readiness_poll.py`: - With nothing listening there is no ownership scan, no error and no probe, and the load still times out the same way (fails on main: one scan plus one false error inside the window). - Once something listens, the ownership check runs on every poll before the keyed probe: a refused first answer is asked again and the key goes out only after a yes. Repeated non-200 probes are each preceded by a fresh check, and the load still times out. - A listener that is not owned by our child is still refused with the same error. - With a listener whose owner psutil cannot name, mocked Windows still probes it and Linux/macOS still refuse. - `_port_accepts` sends no bytes, returns False once the listener is gone, and follows an IPv6 `[::1]` URL. The 5 behaviour tests pass on main and on this branch. The other 3 fail on main as expected. The related suites (managed engine, engine ports, API key transport, llama-server port owner, sidecar port owner, health wait, STT sidecars, IPv6 loopback hold, WSL host, NPU failure output) were run on main and on this branch, and the failing test IDs were compared. No test fails only on this branch: - In the parallel run, two timing tests failed only here: `test_a_load_that_stalls_times_out_one_timeout_after_its_last_work` and `test_runner_stops_the_engine_group_when_studio_closes_the_pipe`. Both pass on a serial rerun here, and the WSL runner test then failed on main. - `test_unload_waits_for_inflight_transcription` is timing sensitive on both arms. - Four ROCm and support-probe tests fail on main and here alike.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Listener and outbound-address hardening:
[::1]:<port>. Otherwise a sandboxed tool or another local user could listen there and catch the browser'slocalhosttraffic, including the session token. URLs and origins are unchanged.Tests: each change has a test that fails on main and passes here; the provider, launcher and sidecar suites pass on both.