#1 [high] PR 548 overview and scope
PR #548 "Add request latency histograms and process metrics" (draft, opened 2026-11-26, head ebecef1, 8 files +545/-20). Closes #536 (opened by Napuh, a non-maintainer; asks for vLLM-parity request histograms + process_* metrics).
Files: docs/api.md (+25/-3), helios/src/server.rs (+2), helios/src/server/http.rs (+6/-1), helios/src/server/latency.rs (+27/-8), helios/src/server/metrics.rs (+228), helios/src/server/metrics/process.rs (new +184), helios/src/server/runtime.rs (+38/-8), helios/src/server/runtime/phase_tests.rs (+35).
What it adds:
- metrics.rs: generic
Buckets<const N>{ bounds: [f64;N], scale: f64 } consts REQUEST_SECONDS(Buckets<21>), TOKEN_SECONDS(Buckets<19>), PROMPT_TOKENS(Buckets<21>, scale 1.0);Histogram<const N>{ counts: [AtomicU64;N], sum: AtomicU64 } with observe(buckets, u64) + render(text, name, help, buckets) that writes# HELP flare_{name};RequestTimes{ first_scheduled_ns: Option, first_token_ns: Option, last_token_ns: u64 }; six new Metrics fields (request_e2e pub(super) Histogram<21>, request_queue/prefill/decode Histogram<21>, time_per_output_token Histogram<19>, request_prompt_tokens Histogram<21>);Metrics::request_completed(arrival_ns, times, prompt_tokens, generated_tokens)incrementscompletedthen observes. - runtime.rs: Incoming.times, stamped in Worker::complete (first/last token ns, completed_at_ns) and Worker::reserve_and_pack (first_scheduled_ns); both former
self.metrics.completed.fetch_add(1, ...)sites (Worker::complete stop path ~1836, Worker::publish ~1993) now call request_completed. - latency.rs: FirstResponseSamples gains
histogram: Histogram<21>besidewindow: Mutex<Samples>; output() observes; newrender_histogram(separate impl block at 122-131). - server.rs:
state.first_response.render_histogram(&mut text)at 671;metrics::process::render(&mut text)at 709. - http.rs: e2e observed in Delivery::Complete for streaming (615) and non-stream (632), guarded by
if !count(count = path is /v1/messages/count_tokens). - process.rs (Linux only): /proc/self/stat parse_stat, /proc/stat btime, /proc/self/fd count, getrlimit(NOFILE); six metrics; per-source Option fallbacks;
metric()helper (takes impl Display, no flare_ prefix); non-Linux stublet _ = text;. - api.md: new paragraphs listing histograms and process metrics.
Repo rules relevant to lens D:
- AGENTS.md L188-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."
- AGENTS.md L194-199 "Require focused, meaningful validation... source-text checks and mocks that bypass the behavior cannot establish runtime correctness."
- AGENTS.md L16-18 / docs/design-review.md principle 1: "Keep Helios as simple as possible."
- AGENTS.md contribution rules L165-169: contributions must address a maintainer request, demonstrated defect, measured perf/memory problem, or inaccurate docs.
- design-review.md principle 15 (scope) and 16 (prose).
- .agents/skills/repo-prose/SKILL.md: present-state spec, no hidden context, no bloat.
#2 [high] Findings: lens D (simplicity) on PR 548 — final list
PR #548 "Add request latency histograms and process metrics" (draft, head ebecef1, 8 files +545/-20, closes #536). Lens D (simplicity) findings, all verified against the diff and surrounding code.
-
[should fix] Duplicate histogram plumbing — helios/src/server/metrics.rs:212-298 (
Buckets/Histogram) vs the existing host-cache histogram code at metrics.rs:200-210 (HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS as[u64; N]), 670-692 (host_lookup_cost), 1029-1065 (render loop writing_bucket/_count/_sumand+Inf). The PR adds a second, differently-shaped histogram mechanism (f64 bounds +scaledivisor +impl Displayrender) while three existing series already render the same exposition. Fix: makeHistogram<N>/Buckets<N>the one mechanism and delete HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS plus the 1029-1065 block; or, smaller still, dropHistogramand reuse the existing u64-bucket arrays, since two of the three new seconds histograms share one bound list. -
[should fix] The
scale: f64field is redundant — metrics.rs:214-241, 260-270, 291-295. Every observation is already ns;scaleis used only asvalue as f64 / scalefor bucketing andsum / scalefor rendering. Smaller version: keep bounds in ns as[u64; N]like the existing HOST_*_BUCKETS and divide by 1e9 once at render. This removes thescalefield, the PROMPT_TOKENSscale: 1.0special case, and the "integer grid / correctly rounded" comment at 261-262. -
[should fix]
request_prompt_tokensdoes not need a histogram type at all — metrics.rs:235-241, 332, 471-472, 1419-1424, plus the docs/api.md paragraph. Prompt size is a whole-token count and the repo already exposesflare_prefill_tokens_totalandflare_cache_reused_tokens_total. If the per-request distribution is genuinely required, share the existing renderer with a fixed bucket list; as written it is the largest of the six added histograms (21 atomics + sum). -
[should fix] Separate
render_histogramat latency.rs:122-131 is a third impl block onFirstResponseSamples, takes&mut Stringand hard-codes the metric name, and exists only because the histogram lives onFirstResponseSamples(constructed at server.rs:313). Smaller version: move theHistogram<21>ontoMetrics(which already ownsrequest_e2e), observe it fromFirstResponse::outputthrough a metrics handle as http.rs does for e2e; then deleterender_histogram, the extra impl block, and the scrape line at server.rs:671. -
[should fix]
#[cfg(not(target_os = "linux"))] { let _ = text; }at metrics/process.rs:12-15 is dead code that silences an unused parameter. Other platform-gated code in helios uses real empty branches orcfg'd item bodies (runtime_core/protection.rs:298-301, core/cache.rs:4196). Smaller version: gate the wholerenderitem on linux and gate the call at server.rs:709. -
[should fix] process.rs re-implements
metric()(metrics/process.rs:42-49) differing from metrics.rs:1597-1602 in that it takesimpl Displayand omits theflare_prefix. No caller needsimpl Displayfor anything but f64/u64. Keep one writer. AGENTS.md L188-193 rejects abstractions and churn without a concrete requirement. -
[should fix] Four per-source
Optionfallbacks inrender_linux(metrics/process.rs:55-131: sysconf_SC_CLK_TCK/_SC_PAGESIZE,getrlimitreturn,read_dir,parse_stat) are speculative robustness with no concrete requirement and cost more code than the metrics they guard (fourif let (Some, Some)blocks, twothen_somesites). Smaller version: read both sysconf values once, default the page size as eos/src/unix.rs:74 already does (unwrap_or(4096)), and let the rest fail early. The module doc's "a scrape never fails and never panics" is a guarantee nothing in the repo requires forprocess_*. -
[nit]
parse_statskip arithmetic (metrics/process.rs:21-32) — thevalue(11)/value(0)/value(6)/value(0)/value(0)chain plus the "token N - 3" comment is harder to check than naming the fields. Smaller version:split_whitespace().skip(11)thennext()in field order. -
[nit]
last_token_nsduplicates existing scheduler accounting — runtime.rs:1774-1775 stamps first/last token ns inWorker::complete, while the scheduler already maintainsaccounting.last_output_ns(scheduler/policy.rs:275, surfaced at runtime.rs:1172-1173, used at policy.rs:478). Only the first-token instant has no existing home. Smaller version: keepfirst_token_nsonly and read the last-token instant from accounting; deletes oneu64per in-flight request and one store per committed token. -
[nit] Comment bloat: metrics.rs:212-213, 243-244, 261-262, 300 (four doc comments around three struct fields), runtime.rs:193 and 2189-2190, process.rs:1-6. metrics.rs:261-262 explains an invariant the code should not have (finding 2); runtime.rs:2189-2190 only makes sense if the reader knows
reserve_and_packhas a second caller. The prose skill asks comments to explain invariants, not defenses. -
[nit] Part of
request_histograms_bucket_completed_request_timings(metrics.rs:1674-1701) proves nothing about the PR's claim: thefirst_scheduled_ns: Nonesecond observation asserts counts stay at 1, exercising the helper's branch rather than the runtime stamping. The stamping is covered by runtime/phase_tests.rs:576-583 (count == 1), which itself asserts only that a count exists, not a bucket. AGENTS.md L194-199. -
[nit] phase_tests.rs:4428-4432, 4461-4471, 5380-5389 bolt
render()string assertions onto three pre-existing tests (first_response_http_*,metrics_route_*), restating what metrics.rs:1652 and the latency tests already prove and making unrelated tests brittle to HELP-text edits. Keep only theprocess_resident_memory_bytespresence check in the route test as the one end-to-end check. -
[nit] docs/api.md +25 lines enumerates eleven series, repeating definitions that the HELP strings at metrics.rs:1393-1423 carry verbatim. Keep the two facts a scrape cannot supply: histograms are absent from
format=json, andprocess_*is Linux-only; point at the scrape for the rest.
Non-findings verified: state.model.metrics_handle() at http.rs:603 is required by the filter_map closure; if !count correctly excludes /v1/messages/count_tokens, which server.rs:584 routes to the same http::generate handler; RequestTimes survives parking because park moves Incoming wholesale (runtime.rs:2096, 2121) and readmission reuses it.
Repo rules cited: AGENTS.md L16-18 and docs/design-review.md principle 1 ("Keep Helios as simple as possible"); AGENTS.md L188-193 (reject unsupported abstractions and churn); AGENTS.md L194-199 (focused, meaningful validation); .agents/skills/repo-prose/SKILL.md L38-46 (comments explain invariants).