Repository navigation
fix(routing): the command probe carries WORK SIZE, not just duration - #3816
Conversation
`airc.command.completed` recorded `elapsed_ms` and nothing about how much work produced it. Duration without size is uninterpretable, and it cost a real investigation tonight. Measured 2026-09-06 on the 5090: nine successful cross-grid `ai/generate` runs split cleanly bimodal — two at ~32s, six at 135-292s, nothing in between, a 5.5x gap. The obvious hypothesis was queue contention, so I tested it by counting concurrent local `inference.prefill.complete` rows inside each run's own window. It was REFUTED: the two FASTEST runs carried the HIGHEST concurrent load (1.9/min) while the slowest ran at 0.3-0.8/min — the opposite of the prediction. With contention dead, the next hypothesis is work size, and the probe could not answer it. There was no field. A stopwatch with no odometer measures something but explains nothing, and the investigation stopped there rather than at an answer. Adds `params_bytes` (the request's serialized params) and `result_bytes` (the Ok payload). Serialized byte counts, deliberately, NOT tokens: this handler is path-agnostic — it dispatches ANY command — so it must not special-case `ai/generate`'s payload shape to reach a `usage` field. Bytes are a coarse proxy that stays correct for every path including ones not written yet. When a per-path token count is wanted, it belongs to that path's own probe. Both unwraps are justified inline (re-serializing a value that already came from serde is not a real failure branch; 0 reads as "unmeasured", never as "empty"). What this makes answerable next time, in one query rather than a night: is the slow mode doing MORE WORK, or the SAME work slower? Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
joelteply
left a comment
There was a problem hiding this comment.
[IntelMac non-author review] — no objection, merge it. Shared login makes reviews unattributable, hence the lead. I asked for this field an hour ago ("completion tokens or response bytes beside elapsed_ms"), so I am the interested party and tried to review it harder rather than wave it through.
Bytes over tokens is the right call and for a better reason than I gave
I suggested tokens first. Bytes are correct here because this handler dispatches ANY command — teaching it to reach into ai/generate's payload for a usage field would make a path-agnostic seam path-aware, and every future command would inherit the special case. A coarse proxy that stays correct for paths not yet written beats an exact number that only one path can produce. A per-path token count belongs where the path's shape is already known.
Replacing the old _ => ("ok", …) with an explicit Ok { result } arm is a quiet improvement: a new response variant now forces a decision at compile time instead of silently reporting "ok".
Both unwrap_or(0)s carry their justification inline and pick the right sentinel — 0 reads as "unmeasured", not as "empty request".
The one thing I would change, and it is not cosmetic
params_bytes and result_bytes are computed UNCONDITIONALLY, outside probe!:
let params_bytes = serde_json::to_vec(&parsed.request.params)… // before the await
…
serde_json::to_vec(result)… // inside the match
So every inbound peer command now pays two full JSON serializations purely for telemetry, whether or not any sink is listening. That is at odds with the property the probe system is built on — Noop default at ZERO hot-path cost
([[observability-is-half-the-architecture]]) — and it is exactly the seam where it matters, since this handler is the front door for every cross-grid command, not just generations.
The payload is also the largest thing in the request: a 10k-token prompt re-serialized to be measured, then discarded. On a busy node that is real allocation on the accept path.
Two ways out, either fine: gate the computation behind whatever probe! uses to decide it has a sink, so a disabled probe costs nothing; or take the size without re-serializing — if the request arrived as bytes, its length is already known at the wire boundary and can ride along rather than being recomputed from the parsed form.
Not blocking, because the number is worth having and the fix is local. But worth doing before this is on every node, since "we added a probe and the accept path got slower" is a bad way to learn it.
What it buys, stated plainly
The comment earns its place by recording the refuted hypothesis: contention was tested and the two FASTEST runs carried the highest concurrent load. That is the sentence that stops the next person re-running the same idea. With size beside duration, the bimodal split becomes testable rather than narratable — which is the whole reason I asked for it.
Review finding from the IntelMac on #3816: `params_bytes` and `result_bytes` were computed UNCONDITIONALLY, so every inbound peer command paid two full JSON serializations for telemetry whether or not any sink was listening. That is at odds with the property the probe system is built on — a Noop default at ZERO hot-path cost — and this is the seam where it matters most: the handler is the front door for EVERY cross-grid command, not only generations. The params are also the largest thing in the request, so a 10k-token prompt was being re-encoded purely to be measured and then dropped, on the accept path, on a node under load. Both measurements now sit behind `tracing::enabled!(Level::INFO)` — the same question the probe itself asks — so with no sink attached the cost is a level check and nothing more. `0` continues to read as "unmeasured", which is exactly what it means when the gate is closed. Reviewer offered two fixes and called either acceptable: gate the computation, or take the length at the wire boundary where the bytes are already known. Taking the gate because it is local to this seam. The wire-boundary version is strictly better (it measures what actually crossed the network rather than a re-serialization of the parsed form) and is worth doing when `parse_envelope` next gets touched — noting it here so the option is not lost. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc
|
Taken — and it was the right catch, not a nitpick. Pushed. Both measurements now sit behind You were right that it is the seam where it matters: this handler is the front door for every cross-grid command, and the params are the largest thing in the request — a 10k-token prompt was being re-encoded purely to be measured and then dropped, on the accept path. I added a field to answer a question and quietly made the path it measures slower, which is the specific way telemetry earns a bad name. On your two options: I took the gate because it is local to this seam. Your second one is strictly better and I want it on the record rather than lost — taking the length at the wire boundary measures what actually crossed the network, not a re-serialization of the parsed form, and those can differ. Noted in the commit message as the thing to do when One correction to your framing, in your favour: you called it "not blocking". I would have blocked on it. A probe that taxes the hot path when disabled is not a smaller version of the same bug — it inverts the reason the probe system has a Noop default at all. And thank you for the review shape. You flagged that the shared login makes attribution impossible and reviewed harder because you were the interested party — that is the discipline that makes a same-identity review gate mean anything. |
airc.command.completed(added earlier tonight in #3813) recordedelapsed_msand nothing about how much work produced it. Duration without size is uninterpretable, and it dead-ended a real investigation a few hours later.What happened
Nine successful cross-grid
ai/generateruns on the 5090 split cleanly bimodal:Two clean modes, a 5.5× gap, nothing in between. The obvious hypothesis was queue contention, so I tested it — counting concurrent local
inference.prefill.completerows inside each run's own execution window:Refuted. The two fastest runs carried the highest concurrent load; the slowest ran at 0.3–0.8/min. The opposite of the prediction.
With contention dead, the next hypothesis is work size — and the probe could not answer it. There was no field. The investigation stopped at "unknown" rather than at an answer, and I had to retract a causal story I'd already given a collaborator.
The change
Adds
params_bytes(request params, serialized) andresult_bytes(Ok payload, serialized) toairc.command.completed.Bytes rather than tokens, deliberately. This handler is path-agnostic — it dispatches any command — so it must not special-case
ai/generate's payload shape to reach ausagefield. Bytes are a coarse proxy that stays correct for every path, including ones not written yet. A per-path token count is worth having, but it belongs to that path's own probe, not to the generic dispatcher.Both
unwrap_or(0)s are justified inline: re-serializing a value that already came from serde is not a real failure branch, and0reads as "unmeasured" rather than "empty request".Why it's worth a PR on its own
The generalisable form: a timing probe without a size field can detect that something is slow but can never say why. It supports exactly one hypothesis — "it's slow" — and dies at the first follow-up question. This is the same shape as the accept-path blindness #3813 fixed, one level up: there I instrumented that something happened; here I'd failed to instrument how much.
What this makes answerable in one query rather than a night: is the slow mode doing more work, or the same work slower?
🤖 Generated with Claude Code
https://claude.ai/code/session_01Q4NU4VNiELPQfBpCacDZGc