Architecture & scope review — PR #548 "Add request latency histograms and process metrics"
Head reviewed: a34c4d0 (includes the two follow-up commits d64c3ea3 and a34c4d06). All 10 changed files read with surrounding code; judged against the charter, AGENTS.md, docs/design-review.md, and the surrounding Helios code.
Key findings
Verdict: should-fix issues only — no blocking architectural defect. The approach is right and the code is careful: recording the observations inside the single function that already counts completions is the correct place, the stamps survive preemption, format=json and Snapshot are untouched, and nothing crosses the preparation/runtime boundary or branches on model identity. Four should-fix items remain, one of them narrow (two accessors in eos), one a scope/authorization question for a maintainer rather than a code defect.
- Should fix — layering:
process.rs:56-70still reads_SC_CLK_TCKand both/procfiles inline, and now readsRLIMIT_NOFILEthrough the mutating helperraise_open_file_limit(0), which is only mutation-free by accident (eos/src/unix.rs:145). - Should fix — scope: the PR is authorized by, and closes, an outside feature request framed as vLLM dashboard parity.
AGENTS.md:165-169,201-203and the charter's "What gets merged" do not list a feature request among the merge criteria. - Should fix — duplication: a second histogram implementation and a second metric formatter now coexist in
metrics.rswithout the existing host histograms being migrated onto them (AGENTS.md:188-193). - Should fix — evidence: "nothing about serving changes" is asserted, not measured, although the change adds a clock read per scheduled step and blocking
/procreads per scrape (docs/design-review.md:97-105).
Nits: the fallback-layer structure of process.rs; a residual population mismatch in docs/api.md; the TTFR histogram being rendered from server.rs while every other family renders inside Metrics::render.
Should fix
1. Residual OS access in the serving metrics module, and a mutating helper used as a getter
helios/src/server/metrics/process.rs:56-70
The two follow-up commits did fix most of what I flagged earlier: process.rs:61 now calls crate::os::page_size() (eos/src/unix.rs:73-75), :68 calls crate::runtime_core::open_descriptors() (helios/src/runtime_core/protection.rs:291-302, re-exported at runtime_core/mod.rs:58 (not opened)), and the hand-rolled getrlimit is gone. What remains, against AGENTS.md:20-22 ("The eos/ crate holds the host operating-system operations that Helios and Selene use"):
process.rs:58-60callslibc::sysconf(libc::_SC_CLK_TCK)directly, whileeosalready owns the sibling_SC_PAGESIZEcall atunix.rs:73. Two lines ofunsafe libcin a formatting module.process.rs:62-67reads/proc/self/statand the whole of/proc/statinline. This part is defensible as local (it is a metrics-only source with no other consumer), so the ask is narrow.- New, introduced by the last commit:
process.rs:69-70reads the softRLIMIT_NOFILEascrate::os::raise_open_file_limit(0). That function (eos/src/unix.rs:138-165) is a mutator: it works as a getter only becausecurrent >= desiredshort-circuits atunix.rs:145fordesired == 0, sosetrlimitat:160is never reached. A metrics renderer whose correctness depends on that accident is fragile — any future change that treats0as "raise to a floor" would mutate the process's file-descriptor limit during every scrape, from the axum worker thread. There is no read-only accessor ineos, and the call site carries no comment requiring it stay read-only (the comment at:69says "A zero target only reads the current soft limit", which documents the trick rather than forbidding its removal).
Fix: add clock_ticks() -> Option<u64> and open_file_limit() -> Option<u64> (getrlimit only) to eos/src/unix.rs beside page_size, and keep process.rs to parsing and formatting. No new code outside eos.
2. Scope authorization: "monitoring parity with vLLM" is not a merge criterion
PR description ("Closes #536"); issue #536; AGENTS.md:165-169,201-203; charter "What gets merged" and "Alternatives / Competitors"
The whole justification is issue #536, "Metrics: add request latency histograms and process metrics for monitoring parity with vLLM", whose stated goal is to move existing vLLM Grafana dashboards onto Flare. The rules that bear on it:
AGENTS.md:165-169: "Every contribution must address an explicit maintainer request, a demonstrated defect, a measured performance or memory problem, or inaccurate documentation. … Hypothetical future consumers, agent-generated suggestions, and lint findings alone do not establish a need for a change."AGENTS.md:201-203: "An explicit maintainer request covering the work is sufficient authorization." The converse — that an outside feature request is not — follows directly.- Charter, "What gets merged": "PRs that address a maintainer request, a roadmap item, a reproducible bug, a measured performance/memory issue, or bad docs." The description ties the work to #536 and to nothing else; there is no maintainer request, roadmap item, measured problem or doc defect cited.
- The charter lists vLLM under "Alternatives / Competitors" (alongside SGLang, TensorRT-LLM, llama.cpp (not opened)). Metric-name and dashboard parity with a competitor is not a stated compatibility goal, and
AGENTS.md:188-189warns against "speculative compatibility".
Nothing here is architecturally wrong, and the observability gap is real — tail latency, queue delay, prefill time and decode rate genuinely are unobservable from a scrape today. But the fix is procedural: get a maintainer decision recorded on #536, or reframe the PR around the defect ("tail latency is unobservable from /metrics") instead of vLLM parity. Worth noting for that decision: the same author's sibling PR #553 (vLLM-compatible per-request metrics) was already halted as low-value/off-charter, and #549, #552 and #551 rebuild overlapping observability surfaces — a maintainer should decide the shape of this cluster once rather than merge four variants.
3. Two histogram mechanisms and two metric formatters in one module
helios/src/server/metrics.rs:212-298 vs :200-210,670-692,1029-1065; helios/src/server/metrics/process.rs:47-54 vs metrics.rs:1597-1602
AGENTS.md:188-193 asks reviewers to reject "frameworks, extension points, speculative compatibility, fallback layers … Refactoring must directly support the requested behavior". This change introduces a net-new mechanism where the file already had one:
Buckets<const N>/Histogram<const N>(metrics.rs:212-298) is a second histogram implementation alongside the existingHOST_TIME_BUCKETS/HOST_TOKEN_BUCKETSarrays plus the inline cumulative render loop (metrics.rs:1029-1065) and the hand-written bucket search inhost_lookup_cost(metrics.rs:670-692). The new type is better — it carries bounds and scale together — so the right move is to migrate the three host histograms onto it, which also removes anunwrap()at:689. As written, the file has two bucket-declaration conventions (u64boundaries withu64::MAXas +Inf,metrics.rs:200-210, versusf64bounds withf64::INFINITY,:219-241) and two render paths, with no guidance for the next metric author. The PR already touches both regions, so the migration is in scope.process::metric(process.rs:47-54) duplicatesmetrics::metric(metrics.rs:1597-1602), differing only in that the process names must not take theflare_prefix. That is a legitimate difference expressed by copying the formatter. A singlemetrictaking the full name, with theflare_prefix supplied by the caller, keeps one formatter.
Neither is blocking; both are the "same thing twice in one module" that docs/design-review.md:16-25 (principle 1, "Keep Helios as simple as possible") pushes back on.
4. The serving-cost claim is asserted, not measured
PR description ("Observability only … nothing about serving changes"); docs/design-review.md:97-105; AGENTS.md:194-199
docs/design-review.md:97-105 requires evidence to be connected to claims and unrun checks and material limitations to be disclosed. The added hot-path work is real, if small:
Worker::reserve_and_packnow readsmonotonic_ns()and walksstep.laneson every submitted step to stampfirst_scheduled_ns(helios/src/server/runtime.rs:2191-2203).Worker::completedoes two stores per committed generated token (runtime.rs:1774-1775); itsmonotonic_ns()call is free because the value was already read.- Every
/metricsscrape now does blocking file I/O on the axum worker thread:read_to_string("/proc/self/stat"),read_to_string("/proc/stat")(the whole file),read_dir("/proc/self/fd"), plussysconfandgetrlimit(helios/src/server.rs:709→process.rs:56-70,:99-126)./metricsis the only production caller — the terminal dashboard readsmetrics.scheduler_tracedirectly (helios/src/server/dashboard.rs:381) and never callsMetrics::render— so this cost is bounded to scrapes, but it is a known new cost and is not stated.
Fix: say "the added cost is one clock read per scheduled step and one /proc read per scrape; not measured" rather than "nothing about serving changes".
A related description-only issue: the live-scrape evidence is internally inconsistent. It reports runtime families gaining 5 observations while flare_time_to_first_response_seconds gained 6, then accounts for 5 prompt-token observations ("le=\"64\" gained exactly one … le=\"2048\" gained four") while conceding the deltas "include" this agent session's own requests and "exceed the three requests below". A reviewer cannot check per-request observation counts from those numbers, and no duration is attributed to an individual request, so decode_sum/e2e_sum cannot be cross-checked against the reported completion-token counts (60, 1500, 695). The measurement is also on the AzallazA fork commit 5ffe4d54 with this commit cherry-picked, not on main. That limitation is disclosed, which is correct; the recommendation is to lean on the unit-test evidence (metrics.rs:1649-1697), which does establish the bucket boundaries, and present the scrape as a smoke check.
Nits
process.rs:72-125is a fallback layer for sources that cannot fail independently on Linux. Sixif letbranches (:72,:81,:90,:99,:108,:117) each quietly drop a subset of the series, andstatis re-matched in three of them. The module doc (process.rs:4-6) advertises "a source that cannot be read omits only the metrics derived from it, so a scrape never fails", which is the nested-fallback styleAGENTS.md:188-189dislikes. A singlelet (Ok(stat), Ok(btime), Some(ticks), …) = … else { return }would be shorter and equally safe; the route test atphase_tests.rsalready covers a successful scrape, so per-source degradation is untested behaviour either way.docs/api.md:309-316population mismatch. The doc says "The runtime histograms observe completed generations", butflare_request_prompt_tokensandflare_requests_completed_totalalso count a completion that committed no token, while queue/prefill/decode skip it — the PR's own testrequest_histograms_bucket_completed_request_timingsasserts exactly this (metrics.rs:1681-1696: aRequestTimes::default()completion adds one prompt-token observation and one completed count, no others). Sohistogram_quantileoverflare_request_prefill_secondsversusflare_requests_completed_totaldivides by a larger denominator than the histogram's own base. One sentence would fix it. Likewise:315-316("Cancelled and failed requests enter onlyflare_requests_cancelled_totalandflare_requests_failed_total") reads as an invariant but is approximate: a request cancelled afterrequest_completedalready ran (runtime.rs:1841-1846,:1996-2001) is in both.- TTFR histogram is rendered from
server.rs.render_histogramcorrectly moved into the mainimpl FirstResponseSamplesblock (helios/src/server/latency.rs:63-109), but its call site ishelios/src/server.rs:671, while every other family formats insideMetrics::render(metrics.rs:1389-1424). Harmless split of responsibility; worth a note only.
Verified sound (no finding)
- Counter and histograms cannot diverge. The only
completed.fetch_addinhelios/srcis insideMetrics::request_completed(metrics.rs:459); call sites are the user/text stop inWorker::complete(runtime.rs:1841-1846) and the natural finish inWorker::publish(:1993-2008). - Preemption preserves the stamps.
Incoming.times(runtime.rs:193-194) moves into the parked list and is reused on readmission, so a preempted request's queue/prefill windows stay correct. - Bucket and render arithmetic.
Histogram::observeusesexposed <= boundwithpositionandunwrap_or(N-1); every array ends at infinity; cumulative_countmatches the+Infline (metrics.rs:259-298).saturating_subeverywhere and thegenerated_tokens > 1guard at:471prevent underflow and division by zero in the time-per-output-token computation. - Compatibility.
Snapshotgained no fields (metrics.rs:69-130), soformat=jsonandflare_helios::server::Snapshotdeserialization are unchanged; no Cargo change is needed becauselibcis already an unconditional dependency; Windows compiles to an emptyrender(process.rs:9-14). parse_stat(process.rs:19-37) handles a)inside the command name viarfind(')'), validates the state character, and indexes fields correctly; the test at:141-148pins[11,12,19,20,21], consistent with the synthetic line.- Cancellation exclusion.
http.rs:598-606observes e2e once, beforeyield Delivery::Complete, guarded by!count && !encoder.tool_limit_reached;tool_limit_reachedforcesTermination::Cancelled(encode.rs:598), matchingflare_requests_cancelled_total. Pinned byphase_tests.rs:4604-4613in both stream and non-stream and all three protocols. - No violated invariants. No preparation/runtime boundary crossing, no model-identity branch, no flag or environment switch, no captured-graph operation family, no change to prepared metadata.
Open questions / not covered by me
- Whether a maintainer will record authorization on #536 (item 2). Nothing in the repository can settle this; it needs a maintainer comment on the issue.
- Actual scrape latency and scheduler-thread impact of the added observations (item 4). Only a measurement settles it; no test can.
- I did not review the terminal dashboard path beyond confirming it does not call
Metrics::render, nor the Orbit/metrics?format=jsonconsumer (docs/orbit.md:545(not opened)); neither is changed by this PR. - The Windows build is unrun in the description; CI (
native-serving.yml) covers Linux and Windows helios--features runtime-core,server, so that gap is covered elsewhere.
Link: https://github.com/NVIDIA/hyperflare-inference/pull/548