Full review — PR #548 "Add request latency histograms and process metrics" (head a34c4d06)
Reviewed at head a34c4d06, after the follow-ups d64c3ea3 and a34c4d06: 10 files, +548/−25, draft, base main, closes #536. Citations are to files at that head.
Key findings
The design is right and most of the previous round is genuinely fixed: the e2e observation is now a single site guarded on the tool limit (helios/src/server/http.rs:598-605), pinned by a new test (helios/src/server/runtime/phase_tests.rs:4601-4616); page size and RLIMIT_NOFILE now go through crate::os (helios/src/server/metrics/process.rs:61, :70); the stray impl FirstResponseSamples block is merged (helios/src/server/latency.rs:101-108); docs/api.md now scopes the flare_ naming rule (:290), adds "cumulative since server start" (:297-298), splits HTTP from runtime histograms (:303, :309), states the ≥2-token eligibility (:313-314) and the vision first step (:310-311); Worker::publish hoists its locals like complete (helios/src/server/runtime.rs:1993-1996); and parse_stat's field offsets are corrected (process.rs:31-35, test :141-148).
Two things block: the last commit introduced a cross-feature reference that breaks a documented build configuration, and the evidence section still asserts "nothing about serving changes" while the diff adds scheduler-path and scrape-path work. Then the diff should get smaller, not bigger: roughly a quarter of the added lines (about 130 of 548) are scaffolding, a second histogram mechanism that leaves the old ones in place, or a duplicate exposition owner. Nothing in this review asks the author to add code.
Blockers (2)
B1 — process.rs references a feature-gated module, so --features server stops building
Where: helios/src/server/metrics/process.rs:68
let open_fds = crate::runtime_core::open_descriptors();
helios/src/lib.rs:25-26 declares #[cfg(feature = "runtime-core")] pub mod runtime_core;. helios/Cargo.toml:25 defines server = ["dep:serde", "images", "grammar", "dep:axum", …] and does not include runtime-core (helios/Cargo.toml:21). helios/src/server/metrics.rs:12 declares pub(super) mod process; unconditionally and render_linux (process.rs:56-126) compiles on Linux, so with --features server alone crate::runtime_core does not resolve and the whole server tree fails to compile.
This is a regression from the previous head: everywhere else under server/ respects the gate — helios/src/server.rs:26-29 gates mod session, helios/src/server/runtime.rs:3983 gates mod prompt_tests — and the new call site is the only ungated runtime_core reference there. helios/Cargo.toml:113-118 and :151-170 even declare integration binaries with required-features = ["server", "test-tools"], so server-without-runtime-core is a configuration this very manifest builds.
Documented lanes that break: docs/model-development.md:99-100 (--features server --lib frontend::, --features server --test message_boundaries) and docs/scheduling-runtime-design.md:735-737. CI (.github/workflows/native-serving.yml:63 (not opened),68), flare-cli/Cargo.toml (not opened) and AGENTS.md:317 all pass runtime-core,server, so CI cannot catch this. Note the doc surface is mixed: docs/api.md:958 pairs server,runtime-core, the two lanes above do not.
Fix (subtractive, −2 files): restore the four lines the commit replaced —
let open_fds = std::fs::read_dir("/proc/self/fd").ok()
.map(|entries| entries.filter_map(Result::ok).count() as u64);
and drop the re-export at helios/src/runtime_core/mod.rs:58 (not opened) plus the pub(crate) widening at helios/src/runtime_core/protection.rs:291. If the duplication is unwelcome, move open_descriptors (protection.rs:291-302) into eos/src/unix.rs beside page_size and call it as crate::os::open_descriptors() — that matches AGENTS.md:20-21 ("The eos/ crate holds the host operating-system operations that Helios and Selene use") and the route the same commit used for the other two helpers, but it is larger than reverting.
Verification status: I could not compile here; the claim is the cfg/feature graph above, exhaustive by reading. cargo check --manifest-path helios/Cargo.toml --features server settles it in seconds.
B2 — the evidence section overstates the cost and does not reconcile its own numbers
Where: PR description ("Observability only … nothing about serving changes"; Evidence paragraph); AGENTS.md:194-199; docs/design-review.md:97-105 (not opened).
The change does add serving-path and scrape-path work, all of it small but none of it zero:
- a clock read plus a walk of
step.lanesfor every submitted step (helios/src/server/runtime.rs:2191-2203); - two stores per committed generated token (
runtime.rs:1774-1775); - blocking file I/O on the axum worker thread for every
/metricstext scrape:/proc/self/stat, the whole of/proc/statforbtime, the/proc/self/fddirectory read,sysconfandgetrlimit(helios/src/server.rs:709→process.rs:58-70)./metricsis the only production caller of the text renderer — the terminal dashboard reads snapshots only (helios/src/server/dashboard.rs:128-146(not opened)) — so the cost is bounded to scrapes, but it is a new cost and the description says the opposite.
The live scrape also does not reconcile: 5 runtime observations against 6 first-response observations over a window that includes the agent session's own traffic; no _sum is attributed to an individual request, so decode_sum/e2e_sum cannot be cross-checked against the reported completion-token counts; and the measurement is the fork commit 5ffe4d54 with this diff cherry-picked, not main. "CI covers the first two" is an expectation — head a34c4d06 carries no checks.
Fix (description only, no code): say "no change to serving output; the added cost is one clock read and one lane walk per scheduled step plus one /proc read per /metrics scrape, not measured"; present the scrape as a smoke check, naming the 5-vs-6 population mismatch and the fork base; name the workflow/job for the CI claim or drop the sentence.
Should Fix (3)
S1 — flare_request_e2e_seconds measures a different population than the runtime histograms, and docs/api.md does not say so
Where: docs/api.md:303-307; helios/src/server/http.rs:598-605, :600, :611-624; helios/src/server/runtime.rs:1841-1846, :1993-2014
The guard added in d64c3ea3 is correct and the tool-limit case is pinned by a test (phase_tests.rs:4601-4616). What remains is documentation: the page says e2e "counts each successful generation from admission to the completed response", which reads as one observation per completed generation and equal to flare_requests_completed_total. It is one observation per delivered response, and it is legitimately lower than flare_requests_completed_total in three ordinary cases:
/v1/messages/count_tokensis excluded (http.rs:600,!count);- a stream the client abandons before the final
pollrecords nothing (http.rs:611-624; the observation precedesyield Delivery::Completeat:606); - a multi-choice response where one choice trips the shared
tool_limit_reachedskips the whole response (http.rs:471-476,:526,:563-567), althoughMetrics::request_completedalready observed the choices that finished (runtime.rs:1841-1846,:1993-2014).
Fix: one sentence naming the population — "observed once per delivered response; a response that the runtime counts as cancelled, an abandoned stream, or a count_tokens call records none, so this count can be lower than flare_requests_completed_total." The code guard already exists; only the sentence is missing. (Multi-choice per-generation observation is a product decision for a maintainer, not a defect I would block on.)
S2 — residual OS access in a formatting module, including a mutating helper used as a getter
Where: helios/src/server/metrics/process.rs:58-60, :69-70; eos/src/unix.rs:73-75, :138-165
page_size and the fd count now route through helpers, but two things do not:
process.rs:58-60callslibc::sysconf(libc::_SC_CLK_TCK)directly, whileeos/src/unix.rs:73-75already owns the sibling_SC_PAGESIZEcall. Two lines ofunsafe libcin a formatting module.process.rs:69-70reads the softRLIMIT_NOFILEviacrate::os::raise_open_file_limit(0). That function is a mutator (eos/src/unix.rs:138-165): it works as a getter only becausecurrent >= desiredshort-circuits at:145fordesired == 0, sosetrlimitat:160never runs. A metrics renderer whose safety depends on that accident is fragile — any future "raise to a floor" interpretation of0would mutate the process's fd limit from the axum worker thread on every scrape, and the comment at:69documents the trick rather than forbidding its removal.
Fix: add clock_ticks() -> Option<u64> and open_file_limit() -> Option<u64> (a plain getrlimit) to eos/src/unix.rs beside page_size, and keep process.rs to parsing and formatting. The two /proc reads can defensibly stay local (no other consumer), so the ask is narrow and adds no new module.
S3 — scope authorization: "monitoring parity with vLLM" is not a merge criterion
Where: PR description ("Closes #536"); issue #536; AGENTS.md:165-169, :201-203; charter's "What gets merged" and "Alternatives / Competitors"
The justification is issue #536, framed as moving existing vLLM Grafana dashboards onto Flare. The rules that bear on it:
AGENTS.md:165-169: a contribution must address "an explicit maintainer request, a demonstrated defect, a measured performance or memory problem, or inaccurate documentation"; "hypothetical future consumers … do not establish a need".AGENTS.md:201-203: "An explicit maintainer request covering the work is sufficient authorization" — the converse, that an outside feature request framed as competitor parity is not, follows.- The charter lists vLLM under competitors and asks for no metric-name or dashboard parity;
AGENTS.md:188-189warns against "speculative compatibility".
Nothing 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. The fix is procedural: get a maintainer decision recorded on #536, or reframe the PR around the defect ("tail latency and queue delay are unobservable from /metrics"). Worth deciding once for the cluster: the same author's #552 and #553 rebuild overlapping observability surfaces, and #553 was already questioned as off-charter.
Subtract / Simplify
Subtract / Simplify (~130 of the 548 added lines, ~24%; ~148, ~27%, with the optional cut)
The five request histograms and their bucket lists (helios/src/server/metrics.rs:219-241) are exactly what #536 asks for and should stay as they are. The cuts below remove scaffolding, duplicate mechanisms and duplicate tests, and every one of them is inside code this PR added or touched.
-
Platform gating by shim instead of by cfg — ~7 lines.
process.rs:8-14is a wrapper whose body is#[cfg(target_os = "linux")] render_linux(text);/#[cfg(not(target_os = "linux"))] let _ = text;, and#[cfg(target_os = "linux")]is repeated onparse_stat(:18),parse_btime(:39),metric(:47),render_linux(:56) and the test module (:128). Gate the module and its one call site instead —#[cfg(target_os = "linux")] pub(super) mod process;atmetrics.rs:12and#[cfg(target_os = "linux")] metrics::process::render(&mut text);atserver.rs:709, the patternhelios/src/server.rs:26-29andruntime_core/protection.rs:291-302already use. The wrapper, thelet _ = text;and five of the six attributes go. Worth doing precisely because the Windows build is the one the description says was not run. -
Six fallbacks for sources that cannot fail on Linux — ~30 lines.
process.rs:72-125has sixif letguards (:72,:81,:90,:99,:108,:117), re-matchingstatin three of them, over/proc/self/stat,/proc/stat,/proc/self/fd,sysconf(_SC_CLK_TCK)(positive for any live process) and the file-limit read (alwaysSomefordesired <= current). Onelet Some(stat) = … else { return }plus straightmetriccalls is shorter and equally safe on the only platform that emits anything;parse_stat/parse_btimekeep theirOptionreturns. The module doc (:4-6) currently advertises a "never panics" guarantee that this restructuring does not need. -
A test that asserts the kernel — ~46 lines.
process.rs:150-176and itsvaluehelper (:132-139) assert live/procvalues: resident > 0, virtual ≥ resident,max_fds >= open_fds, fds ≥ 1, start time within the last hour, and six# TYPElines. That is a test of the machine, and it fails on any host where the assumptions do not hold. The series is already proven to reach a real scrape body by the route test (phase_tests.rs:5390-5393,:5398-5399), and the only test that proves something about this code isparse_stat_reads_fields_after_a_parenthesized_command_with_a_paren(:141-148). Keep that one; if a smoke check is wanted, assert the# TYPElines only. -
Convert the three host-cache histograms instead of adding a fourth mechanism — ~50 lines.
Buckets/Histogram(metrics.rs:212-298) is good code — typed bounds, oneobserve, onerender,+Inffromf64::INFINITY— but it now sits beside two hand-rolled implementations in the same file:HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS(:200-210),host_cost_sumsand the three[AtomicU64; 8]arrays (:382-385), the.position(..).unwrap()pick inhost_lookup_cost(:670-692— thatunwrap()panics on a value above the sentinel, exactly the failureunwrap_or(N - 1)removes), and the 37-line render loop with itsu64::MAX → "+Inf"special case (:1029-1065). WithBuckets { bounds: […ns f64…], scale: 1.0 }thelelabels and_sumprint identically,observeuses the same first-match rule, andhost_outcomes_and_capacity_have_bounded_labels_and_cost_histograms(:1785) keeps passing; the only output change is three added# HELPlines. Caveat:renderdivides the sum byscale(:291-295), so ns sums above 2^53 would round where today's host_sumis exact — a trade the new request histograms already make. Leave the retirement histogram (:851-876) alone: it fills set-style gauges fromstore(:705-711), notfetch_add, so it does not fitHistogramwithout a set variant. And do not flatten the new request histograms into[u64; N]arrays — that removes the abstraction and keeps the duplication. -
Put exposition in one owner — ~28 lines. The TTFR histogram hangs off the sampler (
latency.rs:36; forwarder:101-108), is called out of band fromserver.rs:671, and is re-rendered by a test (phase_tests.rs:4466-4471) that duplicates what the route test already checks (:5390-5393); the failed-stream e2e assertion atphase_tests.rs:4428-4432duplicates the same condition the tool-limit test pins. Movingtime_to_first_response: Histogram<21>ontoMetricsand observing it through the handlehttp.rsalready holds removes the field, the forwarder, theserver.rshook and the duplicate test render, and gives one rule for where a new family renders (metrics.rs:1389-1424). Fold in thedocs/api.md:309-316prose that restates the# HELPstrings (metrics.rs:1398-1424) — keep only what a scrape cannot supply (Prometheus-only, cumulative since start, the exclusions) and drop the per-series sentences, ~8 lines.
Optional, author's call: process_virtual_memory_bytes (process.rs:81-89) and process_max_fds (:117-125) are not in #536's table and neither is actionable for a GPU server; dropping them removes ~18 more lines, two doc mentions and two test assertions.
Do not cut: the five bucket lists (metrics.rs:219-241) are the deliverable; the three RequestTimes fields and the two stamp sites are the minimum that yields queue/prefill/decode; request_completed as the single observation point (metrics.rs:452-480) is the right consolidation and is the reason counter and histograms cannot diverge.
Nits (6)
process::metric(process.rs:47-54) duplicatesmetrics::metric(metrics.rs:1597-1602), differing only inimpl Displayvsu64and inprocess_vsflare_prefixes. Two functions that must stay in step on the exposition format — but this is a wash in lines, so do not chase it for the count; note it only so the next author knows which to reach for.parse_stat's state allow-list (process.rs:24-28, plusassert_eq!(parse_stat("42 (no tail)"), None)at:147) validates a value procfs cannot get wrong, and a kernel reporting an unexpected letter would silently drop all four stat-derived series at once. Validating that the five consumed fields parse bounds the same "unrelated text containing)" risk without a fixed alphabet.- TTFR rendered from
server.rs:671while every other family renders insideMetrics::render(metrics.rs:1389-1424) — only if the move in Subtract 5 is not taken. process_open_fdscounts its own directory read (process.rs:108-116), so it is +1 against Prometheus' client_golang. The HELP string discloses it; mentioned because #536's motivation is stock-dashboard parity.- Description wording: "The existing first-response sampler observes … its median gauge and 60-second window are unchanged" — "its" can attach to the sampler or the histogram; make the sampler the subject. Also name the measured SHA, since three commits now sit on
5ffe4d54. - Commit subjects and lead-in: "Hoist completion values and tighten stat parsing" and "Exclude cancelled responses and reuse host helpers" read only against the diff (
docs/design-review.md:139-145(not opened) wants the four-part scheme in the body, which is not visible here); anddocs/api.md:303"The HTTP histograms observe delivery" uses the implementation verb where the next paragraph says "observe completed generations" — name both groups on their own terms.
Verified sound — do not re-derive
Metrics::request_completed (metrics.rs:452-480) is the only increment of completed (:459) and the only observation site, so counter and histograms cannot diverge; preemption preserves the stamps because park moves Incoming whole (runtime.rs:193-194, :2094-2121); bucket math ends at f64::INFINITY with _count equal to +Inf (metrics.rs:259-297); saturating_sub and the generated_tokens > 1 guard prevent underflow and division by zero (:470-479); Snapshot gained no fields, so format=json and flare_helios::server::Snapshot are untouched; parse_stat splits after the last ) and indexes fields correctly (process.rs:19-37); the tool-limit exclusion is one guarded site with a test; cancellation counters are incremented only for pending/parked/active entries (runtime.rs:1317, :1338, :1360, :1407), so docs/api.md:315-316's "enter only …" does hold for requests; no charter invariant is crossed — no model-identity branch, no flag or environment switch, no prepared-metadata change, no preparation/runtime boundary crossing.
Open questions / not covered
- Will a maintainer record authorization on #536 (S3)? Nothing in the repository settles it.
- Actual scrape latency and scheduler-thread impact of the added observations (B2): only a measurement settles it.
- I did not verify the build (B1 rests on the cfg/feature graph) or run the test suite; the Windows build and the full helios suite are unrun here and CI has no checks on
a34c4d06. - Whether the host-histogram migration (Subtract 4) is intended follow-up work or deliberately out of scope — the description does not say.