#1 [high] Orientation: PR 548 scope and repo rules
PR #548 "Add request latency histograms and process metrics" (draft, head ebecef1, base main, 8 files +545/-20, no reviews, no CI; author WynnD, Discord oystersmiles). Closes issue #536 (which asks for vLLM-parity request histograms + standard process_* metrics).
Files: docs/api.md (+25/-3), helios/src/server.rs (+2), server/http.rs (+6/-1), server/latency.rs (+27/-8), server/metrics.rs (+228), server/metrics/process.rs (new, +184), server/runtime.rs (+38/-8), server/runtime/phase_tests.rs (+35). No other files.
Rules that govern a conventions review:
- AGENTS.md:188-193 "Reject unsupported abstractions and churn ... Refactoring must directly support the requested behavior".
- AGENTS.md:203-207 charter: "Keep the runtime small and model-agnostic"; AGENTS.md:1-27 repo map says eos/ "holds the host operating-system operations that Helios and Selene use".
- docs/design-review.md:16-26 principle 1 (Helios simplicity), :125-136 principle 15 (scope), :137-151 principle 16 (prose).
- docs/api.md:287-290 (unchanged by this PR) states "Counter and gauge names start with
flare_" — the new process_* series do not. - AGENTS.md:52-60 requires docs to state support as present qualification; process metrics are Linux-only and docs/api.md says so.
Lens assigned: conventions and duplication only.
#2 [high] Should fix: new Histogram/Buckets duplicates the two existing host-cache histogram implementations
PR adds Buckets<const N> (helios/src/server/metrics.rs:212-241), Histogram<const N> with observe (:259-271) and render (:273-297). Those are a third implementation of the same thing in one module:
- Host cost histograms: buckets
HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS(metrics.rs:200-210), observation inhost_lookup_cost(:670-692,limits.iter().position(...),bucket.fetch_add,host_cost_sums[index].fetch_add), rendering at :1029-1065 (+Infwhenlimit == u64::MAX,_bucket/_count/_sum). - Host retirement: incremental bucket gauges
host_retirement_buckets(:375), filled instore(:705-711), rendered at :851-876 with*ms as f64 / 1000.0.
The new Histogram supersedes (1) exactly: same fixed bounds, per-bucket AtomicU64 counts, one sum atomic. Nothing in the PR converts the existing sites, so the module now carries three bucket-encoding conventions (u64::MAX sentinel vs f64::INFINITY, ms-as-integer vs seconds-as-f64 bounds, and three different field orders: _count/_sum at :1060-1064, +Inf/_count/_sum at :867-876, _sum/_count at :291-296). Prometheus accepts all of them, but a reader maintaining one histogram family now has to know which of three forms it uses, and the u64::MAX sentinel form is strictly worse than f64::INFINITY (observe at metrics.rs:689 has an unchecked .unwrap() on position, which Histogram::observe avoids with unwrap_or(N - 1)).
Why it matters: AGENTS.md:188-193 rejects churn but also asks for "the smallest footprint in shared code" (charter "How We Work"); a second generic histogram next to two hand-rolled ones is the footprint that will be copied a fourth time. Report says the PR and #537 "add different regions" of metrics.rs, so the merge cost of migrating is low.
Fix: build the host cost histograms and the #537 page histograms on Histogram<N>/Buckets<N> (migrating host_missing_tokens/host_transfer_ns/host_prefill_ns and host_cost_sums to Histogram<8> instances is mechanical, and deletes :1029-1065 plus the host_lookup_cost bucket loop). If migration is out of scope for this PR, say so in the description rather than leaving the third form undocumented.
#3 [high] Should fix: process.rs re-implements OS helpers that already live in eos/ and helios::os
helios/src/server/metrics/process.rs (new) reads procfs and libc limits itself:
std::fs::read_dir("/proc/self/fd").ok().map(|entries| entries.filter_map(Result::ok).count() as u64)(process.rs:65-67) is character-for-characteropen_descriptors()in helios/src/runtime_core/protection.rs:290-302 (std::fs::read_dir("/proc/self/fd").ok().map(|entries| entries.filter_map(|entry| entry.ok()).count() as u64)), and near-duplicate of heliopause/src/export/transfer.rs:61-64 and selene's own accounting.libc::sysconf(libc::_SC_PAGESIZE)(process.rs:56) duplicateseos::page_size()(eos/src/unix.rs:73-75), which helios already re-exports ascrate::os::page_size()(helios/src/os.rs:8) and uses at helios/src/cuda.rs:425, :1450. Note the two differ in failure handling: eos falls back to 4096, process.rs omitsprocess_resident_memory_bytesentirely.libc::getrlimit(libc::RLIMIT_NOFILE, &mut limit)(process.rs:68-77) duplicates the call insideeos::raise_open_file_limit(eos/src/unix.rs:138-165), which is also re-exported throughcrate::osand used by helios/src/runtime_core/protection.rs:356. That function already returns the resulting soft limit asOption<u64>, i.e. exactlyprocess_max_fds; callingcrate::os::raise_open_file_limit(current)— or adding a smallopen_file_limit()getter beside it — gives the same number with no new unsafe block.
Why it matters: AGENTS.md repo map says "The eos/ crate holds the host operating-system operations that Helios and Selene use", helios/src/os.rs:6 repeats "Host operating-system operations for native serving" and re-exports flare_eos::*. So a new helios/src/server/metrics/process.rs that calls libc::sysconf/libc::getrlimit//proc/self/fd directly puts a fourth copy of the same OS layer in Helios instead of one line in the module the repository designates for it. The duplication is also already drifting (page-size fallback behaviour above).
Fix: add the missing getters (page_size() exists; add open_file_limit() -> Option<u64> and open_descriptors() -> Option<u64>) to eos/src/unix.rs next to raise_open_file_limit, or reuse crate::os from process.rs; keep only the /proc/self/stat and /proc/stat parsing in process.rs, since nothing parses those today (verified: search_code for btime|_SC_CLK_TCK|/proc/self/stat finds no prior implementation in Rust sources).
#9 [high] Research summary
Reviewed PR #548 through the conventions-and-duplication lens: every changed file (docs/api.md, helios/src/server.rs, server/http.rs, server/latency.rs, server/metrics.rs, server/metrics/process.rs, server/runtime.rs, server/runtime/phase_tests.rs) was read in context, including the callers of each changed function and the precedents cited against it.
Five confirmed findings recorded, plus one nit and a note of candidates I checked and dropped:
- Should fix —
Buckets/Histogram(metrics.rs:212-298) is a third Prometheus-histogram implementation in the same module, next toHOST_TIME_BUCKETS/HOST_TOKEN_BUCKETSwithhost_lookup_cost(metrics.rs:200-210, :670-692) and the rendered loops at :1029-1065 and the retirement buckets at :851-876. Three bucket-encoding conventions now coexist (u64::MAXsentinel vsf64::INFINITY, three different_count/_sumorders). - Should fix —
metrics/process.rsre-implements host OS helpers that already exist:open_descriptors()inruntime_core/protection.rs:290-302(verbatim identical/proc/self/fdcounting),eos::page_size()used viacrate::os::page_size()(eos/src/unix.rs:73-75, helios/src/cuda.rs:425 (not opened)), and thegetrlimit(RLIMIT_NOFILE)call insideeos::raise_open_file_limit(eos/src/unix.rs:138-165), which already returns exactly theprocess_max_fdsvalue. AGENTS.md:20-22 and helios/src/os.rs:6 designateeos/as the home for these. - Should fix —
flare_time_to_first_response_secondsis owned bylatency::FirstResponseSamplesand rendered by a separate hook from the route (server.rs:671), while its siblingrequest_e2elives inMetrics(metrics.rs:327) and every other request histogram is emitted byMetrics::render. Three assembly points for one text body. - Should fix — docs/api.md:287-290 still states "Counter and gauge names start with
flare_", which the six newprocess_*series contradict 27 lines later; the PR does not amend the sentence. - Should fix / nit — the e2e observation is written inline twice in one function in two styles (http.rs:614-616
metrics()in the non-streaming branch vs :631-632metrics_handle()in streaming), the file's own precedent being named helpers. - Nit —
process::metric(process.rs:42-49) duplicatesmetrics::metric(metrics.rs:1597-1602).
Verified non-findings: RequestTimes does not duplicate scheduler::RequestAccounting (the scheduler copy is reset at finish and does not survive park), the latency.rs Mutex<Samples> → {window, histogram} rename updates every use site, and the new SPDX header matches latency.rs:1.
#10 [high] Summary: findings list for the conventions and duplication report on #548
PR #548 (draft, head ebecef1, 8 files +545/−20, no reviews, no CI). Lens: conventions and duplication. Every changed file was read in context. Six findings, none blocking; three should fix on duplication, two should fix on documentation/placement convention, one nit.
-
SHOULD FIX (duplication, largest) — third histogram implementation in one module. New:
Buckets<const N>andHistogram<const N>(observe/render) at helios/src/server/metrics.rs:212-298; bucket constants at :219-241. Existing precedent 1:HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS(metrics.rs:200-210), observation inMetrics::host_lookup_cost(:670-692:limits.iter().position(...)+host_cost_sums[index].fetch_add), rendering at :1029-1065. Existing precedent 2: retirement histogram gauges filled instore(:705-711), rendered at :851-876 with*ms as f64 / 1000.0bounds. Consequence: three bucket encodings now coexist in one file (u64::MAXsentinel vsf64::INFINITY; ms-integer vs seconds-f64 bounds) and three_count/_sumorderings (:1059-1064, :867-876, :286-296). Also the old path'sposition(...).unwrap()at :689 vs the newunwrap_or(N - 1)at :268. Fix: rebuild the three host-cost histograms onHistogram<8>/Buckets<8>, deleting :1029-1065 and the bucket loop in host_lookup_cost; PR says it only touches the completion-counter region, so #537/#548 merge order is unaffected. -
SHOULD FIX (duplication) — process.rs re-implements existing OS helpers. New:
metrics/process.rs:65-67/proc/self/fdcounting,:56libc::sysconf(_SC_PAGESIZE),:68-77libc::getrlimit(RLIMIT_NOFILE). Existing:open_descriptors()at helios/src/runtime_core/protection.rs:290-302 is character-identical;eos::page_size()eos/src/unix.rs:73-75 re-exported ascrate::os::page_size()(helios/src/os.rs:8) and used at helios/src/cuda.rs:425,:1450;eos::raise_open_file_limiteos/src/unix.rs:138-165 performs the same getrlimit and returns the soft limit asOption<u64>— exactlyprocess_max_fds— and is re-exported throughcrate::os(used at protection.rs:356). Convention: AGENTS.md repo map ("Theeos/crate holds the host operating-system operations that Helios and Selene use"), helios/src/os.rs:6. Drift already visible: eos falls back to page size 4096, process.rs omits the metric. Fix: addopen_file_limit()/open_descriptors()besideraise_open_file_limitin eos/src/unix.rs and callcrate::os::page_size(); leave only the/proc/self/statand/proc/stat btimeparsing in process.rs (no prior Rust implementation of those exists — searched). -
SHOULD FIX (convention/placement) — TTFR histogram owned outside
Metrics, rendered from the route. helios/src/server/latency.rs:33-37 (histogramfield), :108-119 (double record: window + histogram), :122-131 (render_histogram), called at helios/src/server.rs:671. Contrast:request_e2eis aMetricsfield (metrics.rs:327), rendered byMetrics::renderat metrics.rs:1386-1430 alongside the runtime request histograms, and observed viametrics_handle()from http.rs:615/:632.metrics::process::renderis appended at server.rs:709. So/metricstext is now assembled at three points with no stated rule. Note the double bookkeeping (VecDeque + histogram for the same duration) is the accepted cost of keeping the 60 s median documented at docs/api.md:329-336; the finding is ownership/render asymmetry, not the double record. Fix: pick one ownership and state it (move the histogram besiderequest_e2e, or document inMetrics::renderthat HTTP-owned histograms are appended by the route). -
SHOULD FIX (documentation consistency) — docs/api.md:287-290 unmodified sentence "Counter and gauge names start with
flare_" is contradicted by the six newprocess_*series documented at docs/api.md:315-318 (emitted at metrics/process.rs:78-127). The names themselves are correct (standard Prometheus process collector names, which is what #536 asked for). Fix: one clause, e.g. "…start withflare_, except the standardprocess_*series below". Matters because the surrounding paragraphs invite{__name__=~"flare_.*"}scrape filters. -
SHOULD FIX (duplication, small) — the e2e observation is written inline twice in one function in two accessor styles: helios/src/server/http.rs:614-616 (
state.model.metrics()-derived clonemetrics) and :631-632 (state.model.metrics()). The file's own precedent is named helpers (failure_log,rejection,rejection_details,with_request_id, http.rs:39-69) and it already capturesstream_state/id.clone()into the closure (:384-385, :601).metrics_handle()here is its second caller in the tree (other: server.rs:511). Fix: oneobserve_e2e(&self, admitted_at)helper; it also drops the repeatedas_nanos() as u64andREQUEST_SECONDS. -
NIT —
process::metric(metrics/process.rs:42-49) duplicatesmetrics::metric(metrics.rs:1597-1602), differing only by theflare_prefix and theDisplayvalue type; the copy also skipsescape_prometheus_label(metrics.rs:1604-1615), which is fine today (no labels) but will not be inherited if a labelledprocess_*series is added. Fix: keep one emitter and pass the full name.
DROPPED after verification (entry 8): RequestTimes vs scheduler::RequestAccounting is not duplication (scheduler copy is reset by finish, does not survive park; CheckpointAccounting::initial_prefill_ns is a prediction, not a measurement); the latency.rs Mutex<Samples>→{window, histogram} rename updates every use site (:73, :111, tests :198/:213/:222); the one-line SPDX header at process.rs:1 matches latency.rs:1.
No blocking finding. The twelve times: Default::default() struct-literal additions (runtime.rs:913, :3254, phase_tests.rs:251) follow the existing pattern and needed no comment beyond the field doc at runtime.rs:193.
#5 [medium] Should fix: time_to_first_response histogram is owned by latency.rs while the sibling request_e2e histogram is owned by Metrics
helios/src/server/latency.rs:108-131 records the same observation twice and stores its histogram outside the metrics registry:
-
FirstResponseSamples(latency.rs:33-37) now holdshistogram: super::metrics::Histogram<21>, andFirstResponse::output(:108-119) callssamples.record(...)(the rolling-window VecDeque) andself.samples.histogram.observe(&REQUEST_SECONDS, ...)for the samenow - started. Two stores of one measurement is the accepted cost of keeping the 60 s median (docs/api.md:329-336documents the JSONfirst_responseobject), but the histogram itself is arguably a request histogram and every other request histogram lives inMetrics. -
Rendering is a third route to
/metrics:Metrics::render(metrics.rs:797) emits the whole text;state.first_response.render_histogram(&mut text)is called from the route handler at helios/src/server.rs:671, aftermetrics.rs:1386-1430has already emitted the request histograms from theMetricsstruct and beforemetrics::process::renderat :709. So the text is now assembled from three places with no shared ordering rule. -
request_e2e— the other HTTP-layer histogram — went the opposite way: it lives inMetrics(pub(super) request_e2e: Histogram<21>, metrics.rs:327) and is observed from http.rs:615/:632 viametrics_handle(). So the two HTTP-observed histograms in one PR are owned by two different structs.
Why it matters: the precedent in this file/module is that a mouse-to-metrics gauge or counter is a field of Metrics sample-and-observed in place (Metrics::progress, Metrics::http_requests at http.rs:142, the dashboard gauges at server.rs:661-708 are computed at render because they are derived from HttpState). The first-response histogram is neither: it is an independent counter with its own lock-adjacent storage and its own render hook. A reviewer cannot tell from Metrics that flare_time_to_first_response_seconds exists, which is what the render() grouping is for.
Fix (either is fine, pick one and state the rule): move first_response histogram ownership beside request_e2e in Metrics and observe it from FirstResponse::output through a handle, or keep the current ownership and note in Metrics::render's doc comment that HTTP-owned histograms are appended by the route. The one thing worth changing is the asymmetry between request_e2e and time_to_first_response, which both measure the same kind of request-level latency.
#6 [medium] Should fix: docs/api.md still says every metric starts with flare_, six new ones do not
docs/api.md:287-290 (unmodified lines) says: "GET /metrics returns Prometheus text exposition format 0.0.4 by default. Counter and gauge names start with flare_, such as …". The PR adds six series that violate that sentence and does not amend it:
process_cpu_seconds_total, process_resident_memory_bytes, process_virtual_memory_bytes, process_start_time_seconds, process_open_fds, process_max_fds (helios/src/server/metrics/process.rs:78-127; documented in the new docs/api.md:315-318).
The new paragraph at docs/api.md:315-318 says only "On Linux the text also carries process_cpu_seconds_total, … for the serving process. Other platforms omit them." — an accurate statement of the new behaviour, but the document now contains one sentence saying every series starts with flare_ and 30 lines later six that do not, with no reconciliation. A reader writing a {__name__=~"flare_.*"} scrape filter, which the paragraph at :287-294 invites, silently loses all six.
Fix: change :288-289 to "Counter and gauge names start with flare_, except the standard process_* series below", or scope the sentence ("Flare's own counters and gauges…"). One clause.
Verified against the code: process.rs:78-127 emits exactly those unprefixed names and nothing else. Note the names themselves are correct — they are the standard Prometheus/prometheus_client process collector names, which is the point of #536 — so this is a documentation consistency finding, not a naming request.
#7 [medium] Nit/should fix: the e2e histogram observation is written inline twice in http.rs, in two accessor styles
helios/src/server/http.rs:614-616 and :631-632 write the same statement twice in two styles:
Delivery::Complete(_) => {
if !count { metrics.request_e2e.observe(&super::metrics::REQUEST_SECONDS, admitted_at.elapsed().as_nanos() as u64); }
None
}
vs
Delivery::Complete(body) => {
if !count { state.model.metrics().request_e2e.observe(&super::metrics::REQUEST_SECONDS, admitted_at.elapsed().as_nanos() as u64); }
(two single-line blocks, one after another in the same function). Both duplicate behaviour the closures' neighbours do not: the streaming branch already clones state (let stream_state = state.clone(); http.rs:384, used elsewhere) and id.clone() (:385, :601), and the same file's ordinary style for a shared helper is a named function (failure_log, rejection, rejection_details, with_request_id, all http.rs:39-69). Note also the inconsistency inside the new code: the streaming branch reaches metrics through state.model.metrics_handle() (which clones the Arc into the closure) while the non-streaming branch calls state.model.metrics() — so the file now shows both accessors for one field, and metrics_handle() gained its second caller in the tree (the other is server.rs:511, the dashboard).
Additionally the e2e observe is the one new metric observation placed inline in the route instead of behind a Metrics method, unlike the runtime histograms (Metrics::request_completed, metrics.rs:449-478) — so the "record in one place" argument the PR makes for the completion counter does not extend to the e2e histogram, which now has two inline call sites that must stay in step with the three delivery branches.
Fix: one fn observe_e2e(&self, admitted_at: Instant) (or a AdmittedAt::elapsed_seconds()), called from both branches; it also removes the as_nanos() as u64 and REQUEST_SECONDS repetition the file otherwise hides.
#8 [medium] Verified non-findings: RequestTimes vs RequestAccounting; SPDX header; latency rename
Checked and NOT a duplication to flag: RequestTimes (metrics.rs:300-306) versus scheduler::RequestAccounting (helios/src/scheduler/policy.rs:53-65). RequestAccounting already holds arrival_ns, last_progress_ns, last_output_ns: Option<u64>, terminal_since_ns and committed_output_tokens, and set_arrival (policy.rs:245-254) already carries the arrival stamp, so the new stamp fields look like a repeat. They are not: RequestAccounting is owned by the scheduler, is reset by finish, and is not readable after park → resume_decoded_sequence (runtime.rs:1556-1575 explicitly rebuilds the request from Parked), while a preempted request must keep its stamps. CheckpointAccounting::initial_prefill_ns (scheduler/checkpoints.rs:24) is a predicted cost, not a measurement. So there is no existing mechanism to reuse — verified in code, not just by comment.
Also not a finding: the ART/phase-test additions (times: Default::default() at runtime.rs:913, :3254, phase_tests.rs:251) match the existing struct-literal noise pattern; no duplication introduced.
Also checked and clean: FirstResponseSamples's Mutex<Samples> → { window, histogram } rename (latency.rs:33-37) touches every use site (latency.rs:73, :111, tests :198, :213, :222) — no stale .0 access left. render_histogram correctly passes REQUEST_SECONDS (latency.rs:128) rather than defining a fourth bucket set, and reuses the same 21 boundaries as the request histograms, which matches #536's request that TTFR "same start and end points as the current median gauge".
SPDX headers: new file helios/src/server/metrics/process.rs:1 is /* SPDX-License-Identifier: Apache-2.0 */, byte-identical to helios/src/server/latency.rs:1 and to the contributor-authored files under helios/src/server/protocol/decisions/. The newer convention for files that started as NVIDIA is the two-line Copyright form (metrics.rs:1-5). Matching latency.rs is defensible; a nit at most, not worth a finding.
#4 [low] Nit: process::metric duplicates metrics::metric line emitter
helios/src/server/metrics/process.rs:42-49 defines fn metric(text, name, kind, help, value) doing "# HELP {name} {help}\n# TYPE {name} {kind}\n{name} {value}", right beside metrics::metric at helios/src/server/metrics.rs:1597-1602 doing "# HELP flare_{name} {help}\n# TYPE flare_{name} {kind}\nflare_{name} {value}" — same three lines, same order, differing only in whether the flare_ prefix is applied and in the value type (impl Display vs u64). The prefix difference is precisely why the copy was written, but the generalisation is one line: metrics::metric could take the already-prefixed name, or gain a flare: bool/Display value parameter, and process::render would reuse it instead of carrying a second line-emitter.
Also note the new helper skips escape_prometheus_label (metrics.rs:1604-1615); no new series takes a label, so nothing is wrong today, but the second emitter will not inherit the escaping if a labelled process_* series is added (e.g. process_io_bytes_total{device=…}), while the shared one will.
Fix: keep one exposition helper in metrics.rs and pass it the full metric name; delete process::metric. Nit if the author prefers to defer.