Key findings
Reviewed PR #548 at head 055663a (9 files, +1016/−51; no reviews, no CI checks) through the conventions-and-duplication lens. Every changed file was read in context, and every finding below was re-verified against the code at that head. No blocking findings. Two should-fix findings, three nits.
The earlier passes' findings are resolved and are recorded only as history at the end: the metrics/process.rs (not opened) module (and with it the duplicate metric emitter, the twin if let Some(stat) guards and the pub(crate) widening of open_descriptors) was deleted in 54e06b30; docs/api.md's flare_ sentence and the duplicated inline e2e observation are fixed. One earlier claim must not be repeated: request_e2e is no longer pub(super); it is a private Metrics field (metrics.rs:406), reached only through Metrics::response_completed (metrics.rs:605-618) from http.rs:606-612. Finding 2 rests purely on the ownership/render asymmetry, not on a visibility break.
Rules applied: AGENTS.md:188-193 ("Reject unsupported abstractions and churn … Refactoring must directly support the requested behavior"), AGENTS.md:20-21 (eos/ holds host OS operations Helios and Selene use), docs/design-review.md (not opened) principles on duplicate representations and scope.
Should fix
1. Buckets/Histogram is the third Prometheus-histogram implementation in helios/src/server/metrics.rs, and the two older ones are left untouched
The new code is the newest and least canonical of three: Buckets<const N> ([f64; N] bounds ending f64::INFINITY plus a scale) at metrics.rs:211-253, with the shared per-unit constants REQUEST_SECONDS (:218-224), TOKEN_SECONDS (:226-232), TOKEN_COUNTS (:234-240), PREEMPTION_COUNTS (:242-247), CHOICE_COUNTS (:249-253); and Histogram<const N> at :255-322 with observe (:272-283), absorb (:285-295) and render (:297-321).
The two precedents this PR does not migrate:
- Host cost histograms —
HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETSas[u64; 8]endingu64::MAX(metrics.rs:199-209),host_cost_sums: [AtomicU64; 3](:475), observation inhost_lookup_cost(:819-841) withlimits.iter().position(|limit| value <= *limit).unwrap()(:838), rendering at :1178-1214. - Retirement histogram —
host_retirement_buckets: [AtomicU64; 8](:468), filled inMetrics::store(:854-860), rendered at :1000-1025 with bounds taken fromflare_selene::RETIREMENT_LATENCY_MSand converted by*ms as f64 / 1000.0.
They disagree on more than encoding, and the disagreement is visible inside a single scrape:
| HELP | order | bounds source | |
|---|---|---|---|
new Histogram::render (:297-321) |
# HELP + # TYPE (:298-301) |
buckets → _sum (:315-319) → _count (:320) |
[f64; N] + scale |
| host cost (:1178-1214) | # TYPE only |
buckets → _count → _sum |
[u64; 8] ending u64::MAX |
| retirement (:1000-1025) | # TYPE only |
buckets → +Inf → _count → _sum |
integer ms, scaled at render |
Why it matters: one module now presents three answers to "how do I write a histogram", so a reader cannot tell which shape a new histogram should take, and the exposition text mixes histograms with and without # HELP. That is exactly the duplicate-representation churn AGENTS.md:188-193 and docs/design-review.md (not opened) ask to avoid — and the PR description names no existing site as a deliberate deferral. This is a code-shape issue, not a behaviour defect: the host-cost position(...).unwrap() cannot panic because u64::MAX terminates the array, and every emitted series is already pinned by existing tests, so a migration can be behaviour-preserving.
Fix (choose one): rebuild the host-cost and retirement histograms on Histogram<8>/Buckets<8>, which deletes metrics.rs:199-209, host_cost_sums (:475), the bucket loop inside host_lookup_cost, and the render loops at :1178-1214 and :1000-1025 plus the fill in :854-860; or state in the description that the migration is deliberately deferred and scope the new type so it does not present itself as the module's histogram abstraction.
2. flare_time_to_first_response_seconds is owned outside Metrics while its sibling flare_request_e2e_seconds is a Metrics field
Both histograms are HTTP-observed and were both added by this PR, but they live in different structs and render through different paths:
flare_request_e2e_seconds— private fieldrequest_e2e: Histogram<21>(metrics.rs:406), observed throughMetrics::response_completed(metrics.rs:605-618) called at http.rs:606-612, rendered in theMetrics::renderhistogram loop (metrics.rs:1548-1581).flare_time_to_first_response_seconds—FirstResponseSamples.histogram(latency.rs:36), observed inFirstResponse::output(latency.rs:116-127), rendered by its own forwarderrender_histogram(latency.rs:101-108), which the/metricsroute calls out of band at helios/src/server.rs:671.
Why it matters: a reader of Metrics cannot learn that the TTFR series exists, and the /metrics body is now assembled at four stages — Metrics::render (server.rs:660), the first-response gauges and median plus the histogram (server.rs:661-671), the input and HTTP gauges (server.rs:672-674 and after), and other collaborators — with no stated ownership rule. The PR's own stated principle ("recorded in the same place as the counter") holds for the runtime histograms and the e2e histogram, but not for TTFR. Note this is only an ownership/render asymmetry: keeping the 60-second median window and the all-time histogram side by side is defensible and is documented (docs/api.md:302-389), because a median cannot be recomputed from an all-time histogram.
Fix: move the TTFR histogram onto Metrics, observe it from FirstResponse::output through the existing metrics_handle(), and delete render_histogram plus the server.rs:671 call — or state in Metrics::render (and in latency.rs) why the window and its histogram must stay together and are appended by the route.
Nits
3. The model_step gate re-spells GraphKind::samples()
runtime.rs:1721-1730 gates the observation with matches!(kind, GraphKind::Prefill | TerminalPrefill | ScoredPrefill | Resume | Decode | Speculative | Mixed) — exactly the set GraphKind::samples() already encodes (helios/src/execution/manifest.rs:90-101), which this very file already uses at runtime.rs:2956 (if !step.kind.samples()). Fix: if kind.samples(), so a new sampling kind does not silently miss flare_model_step_tokens.
4. Per-choice generated-token bookkeeping is duplicated
Encoder already stores the per-choice generated count — Usage { generated: u32 } (helios/src/server/protocol/encode.rs:55-60), set from the same Finished event at :630-634, incremented by observe_generated_token (:216-219) — and already groups choices by prompt through choices_per_prompt (:94) with .step_by(self.choices_per_prompt) (:690-695, for cached). http.rs adds a parallel let mut generated = vec![0u32; size] (:407) filled at :530, and metrics.rs:610 re-groups it with generated.chunks(choices). Two stores and two groupings of one number diverge the first time either path changes — e.g. the zero-max_new_tokens choices at http.rs:315-319 are finished at :441-454 without ever setting generated. Fix: expose the encoder's per-choice counts (or its choices_per_prompt) and observe from that single source.
5. flare_admission_rejections_total bypasses the file's labelled-counter loop
metrics.rs:1643-1656 is hand-rolled with a literal ["http_slots", "generation_capacity", "request_queue"] array zipped positionally against &self.admission_rejections (:423), duplicating the variant order of AdmissionLimit (:376-385) with nothing linking the two, and skipping the table-driven labelled-counter loop that sits in the same file (metrics.rs:1143-1177: for (name, labels, counters) → # TYPE flare_{name} counter → per-label line). Fix: give AdmissionLimit a name()/ALL and feed the existing loop.
Also noted, not raised
The max_new_tokens + reasoning_cut.after sum at runtime.rs:1568-1569 repeats runtime.rs:66-67 (Prompt::output_event_capacity); a Prompt::output_budget() would remove the third copy (phase_tests.rs (not opened) spells it too). Kept as an observation only, because the two sites serve different purposes (capacity sizing vs. observation).
Verified non-findings (checked and dropped)
docs/api.mdprefix sentence is fixed: "except the standardprocess_*series described below" (docs/api.md:287-290); the histogram prose now sits at :302-389 and the vLLM mapping table at :475-522, withpendingdescribed as first-admission-only at :409, matching theflare_pending_requestsHELP text (metrics.rs:1709-1712).FirstResponseSamplesis now a named-field struct (window,histogram, latency.rs:34-37); every use site was updated (latency.rs:73, :111, :119-124; tests :195, :210, :219) and main had a tuple struct (latency.rs:34at main), so the change is not gratuitous churn.Histogram::absorb(metrics.rs:285-295) has one caller (inter_token_latency.absorb(&record.inter_token), metrics.rs:576) and is the mechanism that keeps the per-request histogram out of the shared registry — design-driven, not a duplicate of an existing helper.- Per-unit shared
Bucketsconstants (metrics.rs:218-253) are the pattern the older two implementations fail to follow: evidence for finding 1, not a separate issue. - The new render blocks follow the file's existing table-driven loop style (metrics.rs:1548-1581, :1582-1595, :1596-1624); the admission-rejections block (:1643-1656) is the sole departure, which is nit 5.
RequestRecordnestingRequestTimesinstead of inlining three fields is not a duplicate ofscheduler::RequestAccounting: the scheduler copy is reset byfinish, does not survivepark, and itslast_output_nsmarks publication, not the last committed token.scheduler.rs:1601looked_upandscheduler.rs:1802cache_lookup_tokensfollow the existingcache_lookups/cache_hitspattern on the line above (:1801);flare_cache_lookup_tokens_totalis a new series beside an existing counter trio, which docs/api.md:370-373 documents.
Open questions for the author
- Is migrating
HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETSand the retirement histogram ontoHistogramintended follow-up or out of scope? The description names only #549/#560 as overlapping work and does not say. - Is there a maintainer-preferred home for HTTP-observed series? No doc states one;
request_e2eis the only precedent and this PR sets two.
What could not be verified
The Windows build, any GPU run, a live scrape, and the pre-existing server::protocol::decode::native_prompt_tests::messages_image_hints_end_after_expansion_for_text_and_segmented_templates failure (needs FLARE_TEST_TEMPLATE_DIR). Nothing in this review depends on them: every finding is a code-shape question settled by the cited lines at 055663a.
History (fixed in earlier passes — not re-raised)
metrics/process.rs (not opened) removed in 54e06b30 (deleting the duplicate process::metric emitter, the two adjacent if let Some(stat) guards, and the pub(crate) widening of open_descriptors — helios/src/runtime_core/protection.rs:291 (not opened) is private again with its only caller at :354); docs/api.md:288-289 amended (d64c3ea3); the e2e observation reduced to one site (http.rs:598-605 → now :606-612).