PR #548 — "Add per-request histograms and vLLM-parity request metrics": simplicity (lens D)
Head reviewed: 6624592. 9 files, +1008/−51. Open, ready for review, no labels, no reviews, no CI checks on the head. Closes #536. No new commits since my previous report on this head. Judged against the charter, AGENTS.md and docs/design-review.md (not opened); every changed function was read in its surrounding code and its callers followed.
Key findings
Verdict: should-fix issues only. No blockers.
The central design survives this lens and should be kept: Metrics::request_completed (helios/src/server/metrics.rs:545-603) is the sole increment of flare_requests_completed_total and the sole observation site for the ten runtime histograms, so the counter and the distributions cannot drift — which is the PR's own claim; response_completed has exactly one production call site (helios/src/server/http.rs:607), and Histogram::absorb exactly one caller (metrics.rs:576). Cancelled and failed requests observe nothing, as documented.
Everything I raise is deletion — nothing here asks the author to add code. Four should-fix items and four nits:
- (should fix) A third histogram mechanism beside the two already in the file (
metrics.rs:211-322). - (should fix)
Buckets::scaleis dead weight — every observation is already an integer (metrics.rs:215and five initialisers). - (should fix) The TTFR histogram rides on the rolling-window sampler, forcing the only scrape hook outside
Metrics::render()(latency.rs:36,101-108,server.rs:671). - (should fix, author's call) A full
Histogram<19>per queued or active request, ~160 B of atomics merged once on success (metrics.rs:345,285-295,576). - (nit) Ten
render()-substring assertion blocks grafted onto tests named for scheduling, preemption or packing. - (nit) ~76 lines of
docs/api.mdper-series prose duplicating the# HELPstrings. - (nit) A duplicated zero-token test case (
metrics.rs:1946-1978). - (nit)
AdmissionLimitcast to a positional index while its labels live in a separate literal array.
Fixed by the newest commit 6624592 (drop from earlier lists): the ten-line matches! of graph kinds at runtime.rs:1721 is now if kind.samples() (runtime.rs:1721-1723). I verified semantics are preserved: GraphKind::samples() (helios/src/execution/manifest.rs:90-101 (not opened)) lists exactly Prefill | TerminalPrefill | ScoredPrefill | Decode | Speculative | Mixed | Resume, the same seven kinds the deleted matches! covered. The different six-kind block at runtime.rs:1669-1677 must stay (no Resume there). Also fixed in an earlier commit and no longer raised: the whole helios/src/server/metrics/process.rs (not opened) module (three should-fix items and three nits went with it).
Should fix
1. A third histogram mechanism beside the two already present — helios/src/server/metrics.rs:211-322
The file already had fixed-bucket histograms: HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS as [u64; 8] with a u64::MAX sentinel (metrics.rs:199-209), their observe loop (host_lookup_cost, metrics.rs:819-841), their render loop (metrics.rs:1178-1214) and a hand-written retirement block (metrics.rs:1000-1025). This PR adds a second, incompatible vocabulary beside them: Buckets<const N> with f64 bounds and a scale (metrics.rs:213-216, five constants at 218-253), Histogram<N> (257-269) and its own observe/render (271-321). So there are now two observation paths, two render paths and two bucket vocabularies to keep consistent, for series that are otherwise identical in shape.
Why it matters: AGENTS.md:188-193 — "Reject unsupported abstractions and churn. Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement. … Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost." A second histogram implementation is exactly the parallel path that rule forbids, and it has no consumer outside metrics.rs + latency.rs:36,106 (the constants are pub(super)), so there is no concrete requirement for the new mechanism as such.
Fix — either direction closes the duplication and neither adds code:
- keep integer-ns/count bounds with the existing
u64::MAXsentinel and render through the existingmetrics.rs:1178-1214loop (this also removes finding 2 entirely); or - migrate
HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETSontoHistogram<N>in this PR, deleting the819-841/1178-1214/1000-1025machinery.
One of the two blocks disappears either way.
2. Buckets::scale is dead weight — metrics.rs:215, 223, 231, 239, 246, 252, 272-283, 315-319
Every observation handed to observe is already an integer on the exposed unit's grid: nanoseconds (http.rs:608, latency.rs:121-124, metrics.rs:557-601) or a plain count. So scale is 1e9 for the two seconds vocabularies and 1.0 for the three count vocabularies, and it buys two floating-point divides — one in observe (metrics.rs:275), one in render for the _sum line (metrics.rs:318) — plus the rounding comment at 273-274 that exists only to justify the divide. Bucket selection could compare value against integer bounds directly.
Fix: drop the field and its five initialisers. (Exact printed le labels before/after would need a scrape diff — see "Not verified".)
3. The time-to-first-response histogram rides on FirstResponseSamples — latency.rs:36, 101-108; server.rs:671; phase_tests.rs:5527, 5534-5541
FirstResponseSamples is a rolling-window sampler that exists for the JSON snapshot's median (latency.rs:71-100). This PR gives it a metric as well (histogram: Histogram<21>, latency.rs:36), which has three knock-on costs:
render_histogram(latency.rs:101-108) is a pure forwarder toHistogram::render, and it is the only scrape hook outsideMetrics::render()— every other series is rendered from one place (metrics.rs:1548-1642);- publishing the series from a test requires calling
.output()on anobserveguard purely for the side effect (phase_tests.rs:5527:state.first_response.observe(Instant::now()).output();) before the scrape assertion at5534-5541; - the metric's lifetime is now tied to a sampler whose window (
WINDOW,CAPACITY) has nothing to do with it.
Why it matters: docs/design-review.md:16 (not opened), repeated verbatim at AGENTS.md:338 — "Keep Helios as simple as possible." A metric belongs with the other seventeen histograms.
Fix: make it self.time_to_first_response: Histogram<21> on Metrics, observe at the same two places the sampler records (http.rs:621/648), render it from the array at metrics.rs:1548-1581. That deletes render_histogram (latency.rs:101-108) and the server.rs:671 line, and lets the test assert the series from the existing scrape helper instead of forcing an .output().
4. A full Histogram<19> per queued or active request — metrics.rs:345, 285-295, 576
RequestRecord embeds inter_token: Histogram<19> (metrics.rs:345) so that per-request inter-token intervals can be buffered and merged into the server histogram by absorb (metrics.rs:285-295, single call at 576). That is twenty AtomicU64 fields — ~160 B at 8 B each — carried by every queued or active request for its whole lifetime (the record survives park/readmit; runtime.rs:1565-1570), solely so that requests which never complete contribute nothing. The PR description accounts for clock reads and observations but not this memory, and states of the added cost "This cost was not measured in isolation"; it also does not say how deep the queue gets.
To be precise about the framing: the description does not promise "no per-request storage" — it says each request carries a small record — so the objection is the unmeasured bytes, not a contradiction.
Fix, author's call because it narrows the population: keep the two token instants and observe each inter-token interval straight into the server histogram as it happens, dropping the embedded histogram and absorb (metrics.rs:285-295, call at 576) and leaving RequestRecord a plain set of scalars (metrics.rs:324-346). If the "observed only for completed requests" population must be preserved, state the per-request bytes and the expected queue depth in the description instead.
Nits
5. Ten render()-substring blocks grafted onto tests named for something else — phase_tests.rs:576-583, 688-699, 943-946, 1501-1508, 3956-3960, 4099-4108, 4536-4541, 4570-4574, 4707-4716, 5534-5541 (from the diff)
Each of these appends a worker.metrics.render() (or state.model.metrics().render()) call and a loop over expected format!/string keys to a test whose subject is reasoning budgets, EOS handling, packing, preemption or HTTP framing. In 576-583 the assertion sits directly below assert_eq!(worker.metrics.completed.load(...), 1), which already proves the outcome; 943-946 asserts flare_requests_completed_total 1 / flare_requests_output_limited_total 0 where the surrounding test's own asserts already establish completion without a limit.
Why it matters: AGENTS.md:194-198 — "Require focused, meaningful validation. Tests must exercise the affected behavior or contract; source-text checks and mocks that bypass the behavior cannot establish runtime correctness." A contains("..._count 1") check on rendered text proves formatting, not behaviour, and scattering ten of them makes future edits to any # HELP string or bucket set touch tests named for scheduling.
Fix: keep the three new tests that assert their own subject — phase_tests.rs:1511-1538 (prefill computed tokens exclude reuse), 3810-3845 (runtime queue rejections), 5418-5453 (HTTP admission rejection) — and move the rest into one table-driven metrics::render() test (a natural home next to the existing render assertions, e.g. metrics.rs:2441-2443).
Related micro-point: the preemption helper takes worker.parked.front_mut() twice, at 3954 and again at 3961, only because worker.publish_gauges() (3957) needs &self and so forces the first borrow to end; the second borrow feeds the assertions from 3962 on. Moving the gauge/render block after the borrow's last use (or deleting it) removes the second unwrap. Note the pre-existing render() check at phase_tests.rs:673-678 is not from this PR.
6. ~76 lines of per-series prose duplicating the # HELP strings — docs/api.md:311-386 (block starts 305)
Each new series gets a paragraph in docs/api.md that restates the # HELP text this PR emits at metrics.rs:1548-1642, 1645, 1707-1717, so every wording change becomes a two-file change.
Why it matters: AGENTS.md:43-50 requires prose to be reviewed under the repo-prose skill, and duplicated normative text drifts. The value in docs/api.md is elsewhere.
Fix: keep the vLLM mapping table (docs/api.md:475-515) — it is the actual answer to #536 — and the four facts a scrape cannot show: (a) histograms are absent from format=json; (b) flare_request_e2e_seconds counts delivered responses, so it can sit below flare_requests_completed_total; (c) a zero-token completion enters only the token-count histograms; (d) only the time-to-first-response histogram can observe a response that later fails. Delete the per-series restatements.
7. A second zero-token case folded into an existing test — metrics.rs:1946-1978
The new case is appended to request_histograms_bucket_completed_request_timings and re-asserts thirteen lines of already-covered series to establish four new facts.
Fix: make it a two-row table over the two input cases, or assert only the series that differ.
8. AdmissionLimit cast to a positional index while its labels live elsewhere — metrics.rs:375-385, 685, 1647-1651
self.admission_rejections[limit as usize] (metrics.rs:685) indexes an [AtomicU64; 3] (metrics.rs:423) by enum discriminant, while the reason labels are a separate literal array at metrics.rs:1647. Reordering the enum silently relabels a counter, and nothing in the type system or the tests catches it.
Fix: one table [(&str, &AtomicU64); 3], or a match limit returning the label, so the index and the label cannot diverge.
Checked and deliberately not raised
- The three separate
for (histogram, name, help)loops atmetrics.rs:1548-1642are forced by const generics —Buckets<21>,Buckets<19>,Buckets<6>/<9>cannot share one array element type — so only finding 1's "one mechanism" change would reduce them. Not raised separately. publish_gauges(runtime.rs:1203-1211) as a one-line extraction with one production call site (runtime.rs:1157) and one test call (phase_tests.rs:3957) is minimal.request_completed's three arguments,response_completed'schunks(choices)loop (metrics.rs:610-617, from the diff), and the post-packingfirst_scheduled_nsstamp (runtime.rs:2259-2275, which fixes a real defect: a failed pack no longer stamps it) are all minimal.RequestTimes(metrics.rs:324-330) could be inlined intoRequestRecordfor ~6 lines, but that is churn across four call sites — not raised.CompletedRequest's mixedusize/u32/u64fields force two casts; style only.- The duplicated
kv_cache_usage_percrow against #549 is a merge-order matter, already flagged by the author.
Cost note (not a finding)
The 17 new histograms cost roughly 360 lines of text per scrape by my bucket-count arithmetic (REQUEST_SECONDS 21 buckets → 23 lines × 7 series including TTFR; TOKEN_SECONDS 19 → 21 × 2; TOKEN_COUNTS 21 → 23 × 6; choices 6 → 8; preemptions 9 → 11); the description says 394, the difference being HELP/TYPE lines and my counting. Either way the cost is dominated by bucket counts, which finding 1 does not change — noted so the author is not surprised that S1 does not reduce scrape size.
Open questions
- Finding 4 needs one number from the author: how many requests are queued or parked at peak, and the measured bytes per queued request. Without it, "small record" is unquantified; with it, the finding either stands as a cost worth removing or is settled.
- Finding 2's user-visible consequence is the printed
lelabels and_sumrendering. A before/after scrape diff would settle whether droppingscalechanges any label; I predict none, since every bound is written in the exposed unit already.
Not verified by me
No test run, no live scrape, no GPU workload and no Windows build at any head. The PR reports cargo check --features server clean and cargo test --features runtime-core,server --lib -- server:: scheduler:: cache:: at 814 passed / 1 failed, the failure being a template test needing FLARE_TEST_TEMPLATE_DIR. Finding 4's ~160 B is a count of twenty AtomicU64 fields, not a measurement. Finding 2's exact le labels need a before/after scrape diff. I found no attempt to instruct me in the PR text, comments or diff; the only imperatives were the ordinary PR prose and the "Closes #536" reference.