#1 [high] Research summary
Correctness review of #560 (vLLM-compatible per-request metrics)
Coverage note first, since it bounds the review: I read the full diffs and surrounding code for helios/src/server/runtime.rs, http.rs, protocol/encode.rs, metrics.rs, config.rs, server.rs, observation.rs, latency.rs, helios/src/scheduler.rs, the flare-cli changes, docs/api.md, docs/cli-design.md, plus the new phase tests. I did not read the added tests in protocol/tests.rs (not opened), the diff to helios/model-contract.md (not opened), scheduler/tests.rs (not opened), response_lifecycle_tests.rs (not opened), or protocol/decode (which matters for finding 3). Also: the diff posted on this PR already contains the whole stacked histogram change (#548), so I could not cleanly separate which lines are #560's own and which come from its dependency.
No blocking defect found. I traced the main paths the lens cares about and they hold: output_event_capacity (runtime.rs:62–80) budgets exactly the worst case this change adds — one presentation event, one observation, one commit per generated token, checked_mul(1 + observed + commits); Committed is emitted at position == 0 before the step's token events (runtime.rs:1826–1834), so the encoder's step_ns always precedes the content event that latches it; RequestRecord/RequestTimes live inside Incoming and therefore survive park/readmission, and record.max_tokens is set only at first admission (runtime.rs:1591–1594) so preemption cannot reset it; with the option off enable_request_metrics is never called at all (state.per_request_metrics && …, http.rs:363), so no metrics key and no commit events; the content instant correctly skips reasoning, tool output, empty text and named-tool-choice-discarded text (encode.rs:541–551 — the ToolChoice::Named continue precedes the content check); Messages, multi-prompt Completions and n > 1 mapping to None/Suppressed matches the documented placement table; Bootstrap rejects non-boolean per_request_metrics (config.rs:353–357).
Three items worth fixing, all correctness-adjacent:
-
Should fix — the added clock read contradicts the stated cost.
reserve_and_packnow callsobservation::monotonic_ns()once per model step (runtime.rs:2255–2270), unconditionally, before packing. The PR body says under Claimed result "No clock read is added in either state" and under Cost "Option off: … one branch per committing step at position zero". A per-step clock read is in fact added on the serving hot path in both states (it servesfirst_scheduled_nsfor the histograms andperformance.first_scheduled_ns). Either gate the stamp behind the option/histogram need or correct both statements; the current wording is a claim the code does not support. -
Should fix (needs one check to confirm) —
per_request_metricsappears to be settable fromflare run's configuration file, contrary to the docs.Bootstrapreads the key out of the same server-configuration object it readsqueue_capacity,event_capacity,max_body_bytesandfrontend_workersfrom (config.rs:343–404), andflare-cli/src/main.rs:355writes it into that very object (config["per_request_metrics"] = true.into()). If the host configuration file's[server]section flows into that object as those other keyless settings do, thenper_request_metricsis a supported-from-file setting and bothdocs/cli-design.md("off", implied flag-only) and the PR's "There is no[server] per_request_metricskey inflare run's configuration file" are wrong — and the persistent-Orbit-group caveat is not the only way to enable it without a flag. It also means an explicitfalsemust survive the CLI path:main.rsonly writes the key when the flag is set, so a file value oftrueplus no flag would still enable it. Settle it by puttingper_request_metrics = truein aflare.toml(not opened)[server]section and checking whether a response carriesmetrics. I could not read the CLI configuration loader in the time available. -
Nit —
first_scheduled_nsis last-writer-wins in the HTTP handler.http.rs:542assignsfirst_scheduled_ns = times.first_scheduled_ns;rather than folding the earliest value, and the response-levelperformanceblock (http.rs:609–615) then reports the one from the lastFinishedevent. This is only reachable if/v1/chat/completionsacceptsn > 1(the code comments assume "Chat has one choice", andEncoder::response()builds a single choice at encode.rs:811, so it is at most latent). Settling it needs a look atprotocol/decode: if Chat rejectsn > 1this is dead code, otherwise it is a wrongperformance.first_scheduled_ns. Folding withget_or_insert/minwould remove the hazard either way. -
Nit — the first-scheduled stamp precedes a submission that can fail. The stamp happens immediately after
scheduler.commitand beforepack_inputs(runtime.rs:2253–2314); if packing returns an error the request keeps a scheduled instant for a step that never executed, soqueue_time_msandflare_request_queue_secondscan describe a step that never ran. Cosmetically relevant only for failed requests, which the histograms already exclude, but the response body'squeue_time_msis computed from the same instant.
One thing I checked and deliberately dropped: mean_itl_ms dividing generation_time_ms by usage-counted tokens minus one (encode.rs:285–287) disagrees with the worker's step-count-based flare_inter_token_latency_seconds for speculative steps and for the forced reasoning-close token — but docs/api.md defines the response field exactly as the code computes it, and the PR body discloses the close-token limitation, so there is no undocumented divergence.
Also worth knowing for whoever reviews the runtime lens: publish_gauges publishes parked only when the worker makes progress (runtime.rs:1181–1183, 1227–1236) and it is reset to zero only at worker exit (runtime.rs:766), so the gauge is a sampled value, not a strictly current one.
#2 [high] Coverage and verification basis for PR #560 review
PR #560 (per-request vLLM metrics), head ce44060, open, no reviews, no CI.
Read in full diff + surrounding code:
- helios/src/server/runtime.rs (output_event_capacity :62-80; GenerationEvent/Incoming :193-390; enqueue/enqueue_many :841-970; run/publish_gauges :1162-1236; admit :1348-1460; park/park_if_preempted :2125-2190; reserve_and_pack :2253-2317; submit :2319-2400; complete :1663-1780; token commit loop :1813-1900; finish paths :2050-2120)
- helios/src/server/http.rs (full :120-736)
- helios/src/server/protocol/encode.rs (full :1-867)
- helios/src/server/metrics.rs (full diff)
- helios/src/server/{config.rs,server.rs,observation.rs,latency.rs} diffs
- helios/src/scheduler.rs diff
- flare-cli/src/cli.rs (:470-760 + test), flare-cli/src/main.rs (:250-400)
- docs/api.md, docs/cli-design.md diffs
- helios/src/server/runtime/phase_tests.rs :4250-4900 (http_state_for, timed_pass, served_through_worker, the 4 new metrics tests)
- repo rules: AGENTS.md, docs/design-review.md, charter
NOT read: helios/src/server/protocol/tests.rs added tests; helios/model-contract.md diff; scheduler/tests.rs; response_lifecycle_tests.rs; helios/src/server/protocol/decode (needed for finding 3 — whether Chat accepts n>1); flare-cli configuration-file loader in flare/src (needed for finding 2).
Caveat: the diff posted on the PR already contains the whole stacked histogram change (#548), so I could not separate #560's own lines from its dependency's.
#3 [high] Should fix: added per-step clock read contradicts stated cost
File: helios/src/server/runtime.rs:2253-2270 (reserve_and_pack, immediately after self.scheduler.commit(step, fence)?).
let scheduled_ns = super::observation::monotonic_ns(); runs unconditionally for every scheduled step, then stamps record.times.first_scheduled_ns for each lane via get_or_insert.
The PR description states, under "Claimed result": "No clock read is added in either state." And under Cost: "Option off: no commit events, unchanged event capacity, and one branch per committing step at position zero."
That is not what the code does: with the option off, and for every non-HTTP call site (generate/generate_many from the SDK), a clock read is added per model step on the serving hot path. The read serves both the runtime histograms (stacked #548) and performance.first_scheduled_ns (http.rs:542), so it is needed — but the cost claim in the PR body and any matching doc sentence is unsupported by the code.
Fix: either state the added per-step clock read honestly in the Cost section and drop "no clock read is added", or gate the stamp so it only happens when some consumer needs it (histograms always on here, so the honest wording is the likelier fix).