#1 [high] PR #548 verdict and verified-sound baseline
PR #548 "Add request latency histograms and process metrics", draft, head ebecef1, base main, 8 files +545/−20, author WynnD (Discord oystersmiles), closes #536. No CI checks on head, no reviews.
Verdict: right shape, right place for the runtime histograms; not ready as-is. 2 blockers (both cheap), several should-fix doc/semantics items, and a large removable margin concentrated in the new process.rs. The core design needs no change: request histograms recorded in the one function that already increments completed.
Verified sound (do not re-derive):
- Counter and histograms cannot diverge: only increment of
completedis helios/src/server/metrics.rs:459 insiderequest_completed(452-480); both former direct fetch_add sites are now calls at runtime.rs:1841-1846 (user/text stop) and runtime.rs:1993-1998 (natural finish). Verified in code. - Stamp survival across preemption:
parkmovesincominginto the parked list (runtime.rs:2094-2121) and readmission reuses it;get_or_insertkeeps earliest stamp (runtime.rs:1774, 2201). phase_tests.rs:576-583 exercises the parked/readmitted path. - Bucket math/render:
observeuses first-matchexposed <= boundwithunwrap_or(N-1)(metrics.rs:260-271); every bound list ends at f64::INFINITY;+Infequals_count; valid Prometheus 0.0.4 text. ns→f64 truncation harmless against the 1 ms smallest bound. - JSON snapshot unchanged: no fields added to
Snapshot(metrics.rs:308+),format=jsonpath returns at server.rs:645-658 before any histogram render. parse_stat(process.rs:19-32) correctly splits after the last ')' so a comm containing ')' cannot shift fields.- Non-Linux: all libc uses in process.rs are inside
cfg(target_os = "linux"); libc is already a helios dependency (helios/Cargo.toml:50); no new non-Linux compile risk visible (Windows not built by author; CI does build/test Windows: .github/workflows/native-serving.yml:20-21,64-68). - No charter architecture violation: no per-model branch, no flag, no env switch, no prepared-metadata or captured-graph change, no new snapshot/JSON field, nothing crosses the preparation/runtime boundary (charter "No per-model special cases or flags"; docs/design-review.md:16,125-128).
/v1/messages/count_tokensexclusion is exactly thecountguard (http.rs:131, used at 615/632); matches the description.- Failure path never observes e2e (http.rs:574-578 returns after Delivery::Failed).
- Discord line present, description follows the why/what/result/evidence scheme (AGENTS.md:74-80); merge-order note about #537 is allowed logistics and the two edits are in different regions of metrics.rs.
#2 [high] Blockers (2)
BLOCKER 1 — flare_request_e2e_seconds includes responses the runtime counts as cancelled, contradicting the invariant this PR's own text states.
Evidence:
- Tool-limit cancellation: http.rs:471-476 drops non-terminal events once
encoder.tool_limit_reached; http.rs:526 finishes the decoder withTermination::Cancelled; http.rs:563-567 callsgeneration.cancel(). - The terminal
Finishedevent still passes (matched as terminal at http.rs:472), the loop then yieldsDelivery::Complete(response)(http.rs:598), and both delivery arms observe e2e unconditionally, guarded only by!count(http.rs:614-617 stream, 631-635 non-stream). - Runtime side: cancelled requests increment
metrics.cancelledand go throughfinish_cancelled(runtime.rs:1317, 1338, 1360, 1407; finish_cancelled at runtime.rs:293-302) and never reachMetrics::request_completed(metrics.rs:452-480). So such a response lands inflare_requests_cancelled_totalANDflare_request_e2e_secondsbut in none of queue/prefill/decode/TPOT/prompt_tokens and not inflare_requests_completed_total. - Racy variant: if the runtime finishes naturally before observing the cancel flag, the same request is counted in
completedand all runtime histograms while the client still seesTermination::Cancelled. Membership is timing-dependent. - Docs claim the opposite absolutely: docs/api.md:312-313 "Cancelled and failed requests enter only
flare_requests_cancelled_totalandflare_requests_failed_total." The PR description repeats it ("does not report cancelled or failed requests in the request histograms"). AGENTS.md:182-186 (reject weakened guarantees) applies to a doc claiming an invariant the code does not hold. Requested change (pick one): (a) skip the e2e observation whenencoder.tool_limit_reached(or thread the termination throughDelivery::Completeand observe only successful terminations) — keeps the stated invariant; or (b) narrow docs/api.md:312-313 to the five runtime histograms and say e2e measures every response delivered to the client. Add one test that drives a request past the parallel tool limit and asserts e2e_count vs cancelled_total. Why: operators will reconcileflare_request_e2e_seconds_countwithflare_requests_completed_total; today they describe different populations and the doc says they cannot.
BLOCKER 2 — the Evidence section overstates and does not reconcile, while the code does add serving-path and scrape-path work. Evidence:
- "nothing about serving changes" is false: reserve_and_pack now takes a monotonic clock read and loops every lane of every submitted step (runtime.rs:2187-2203);
completedoes two stores per committed token (runtime.rs:1774-1775);/metricsnow does blocking procfs I/O per scrape —read_to_string("/proc/self/stat"),read_to_string("/proc/stat")(whole file, only forbtime),read_dir("/proc/self/fd"), twosysconf, onegetrlimit(server.rs:709 -> process.rs:52-133). - The live-scrape arithmetic does not reconcile: "counts gained 5 for each runtime histogram and 6 for the first-response histogram" over a window that also served the agent session's own requests, then "the prompt-token buckets ...
le=\"64\"gained exactly one ...le=\"2048\"gained four, which are the two long prompts plus two session requests" — that accounts for 5 runtime observations but leaves the sixth first-response observation unexplained, and none of the sums is attributed to an individual request. - The measurement is on the AzallazA fork commit 5ffe4d54 with this change cherry-picked, not on
main(disclosed, but the sums are presented as if about the branch). - "CI covers the first two" (Windows build, full helios suite) is an expectation: head ebecef1 carries no checks; the workflow does run both (native-serving.yml:20-21,63-68), so one sentence naming the job or a run closes it. Requested change: state the per-step and per-scrape cost as a known, unmeasured cost instead of "nothing about serving changes"; restate the live scrape as a smoke check with the population caveat explicit (6 vs 5 observations, session traffic included, fork-based tree); keep the unit tests as the primary evidence; name the CI job or drop the sentence. Why: AGENTS.md:194-199 requires describing validation and material limitations honestly; docs/design-review.md:97-105 requires reporting evidence honestly. Cheap: description text only.
#3 [high] Should fix (6)
S1. docs/api.md:305-313 — "one observation per completed generation" is false for decode and TPOT, and the page never says which families a prompt-only request skips.
Evidence: metrics.rs:460-461 observes request_prompt_tokens unconditionally; queue only when first_scheduled_ns is Some; prefill only when first_token_ns is also Some; decode/TPOT only when first_token_ns is Some && generated_tokens > 1 (metrics.rs:462-479). The PR's own HELP strings already say "for completed requests with at least two generated tokens" (metrics.rs:1406-1418) while queue/prefill/prompt HELP say only "for completed requests" (metrics.rs:1395-1404, 1419-1424) — so the operator doc contradicts the exposition it describes. Consequence: flare_request_decode_seconds_count < flare_requests_completed_total by design, and the families do not share a denominator.
Fix (one sentence): split by eligibility — queue, prefill and prompt tokens for each completed generation that reached a model step; decode and time-per-output-token only for generations with at least two tokens. Keep the test that pins it (metrics.rs:1684-1697 second call with generated_tokens=1) — do NOT delete it (Subtractive suggested dropping it; that would remove the only evidence for the exclusion).
Also fold in: say the histograms are cumulative since server start (the page's "Totals count from server start" note at :329-330 sits beside a 60 s windowed median, so a reader can take them as windowed), and replace the vague lead-in "Request histograms observe the served response" (:300-301) with the two groups: HTTP-level response timing (e2e, TTFR) and runtime per-request timing (queue, prefill, decode, per-token, prompt tokens).
S2. docs/api.md:301-304 — e2e end-point and coverage are wrong.
Code: streaming observes inside the SSE filter_map at http.rs:614-617, so only if the client polls to Delivery::Complete; non-streaming observes in the handler at http.rs:631-635 before the body is handed to axum, so it records even if the client never reads it. The PR's own tests pin both (phase_tests.rs:4407-4434 unpolled stream leaves e2e at 0; 4437-4473 non-stream records 1 with poll_body=false). The interval ends at delivery completion, not at the model's last committed token, so it is not comparable with flare_request_decode_seconds; and an abandoned/never-polled stream records nothing — exactly the slow-client case an operator investigates.
Fix: "…counts each successful generation whose response the client reads to the end, from admission to delivery completion" and keep the TTFR caveat; or record e2e on the runtime completion path so both transports agree (larger change, not required).
S3. docs/api.md:288-289 — "Counter and gauge names start with flare_" is falsified by the six process_* series the same PR documents at :315-318 and emits at process.rs:78-132. Precedent for the fix already exists at docs/api.md:334-336 ("under its Prometheus name without the flare_ prefix"). Fix: scope the sentence to runtime metrics or add "except the standard process_* series below". Cost: one clause. Also matters because the surrounding text invites {__name__=~"flare_.*"} filters, which would silently drop all six.
S4. docs/api.md:306-308 — flare_request_prefill_seconds absorbs vision work.
first_scheduled_ns is stamped in runtime.rs:2191-2203 over every step.lanes entry, before the if step.kind == GraphKind::Vision split at runtime.rs:2208, and step.lane_kind(row).is_prefill() is available and used for other purposes at runtime.rs:2281. So for a multimodal request arrival→first vision step is "queue" and vision+prefill→first token is "prefill"; the same page uses the narrower convention for prefill_tokens ("excluding padding and prefix reuse", :340).
Fix (cheapest): reword :307-308 to "the request's first model step to its first committed generated token (including a vision step that runs first)". Alternative: narrow the stamp loop to prefill lanes. Either is fine; the doc change is one phrase.
S5. Layering — the new metrics module hand-rolls three OS primitives that already exist one crate down, plus one duplicate inside helios.
- AGENTS.md:20-21: "The
eos/crate holds the host operating-system operations that Helios and Selene use"; charter "Solve the right problem in the right place… Good ideas in the wrong place will be declined". libc::sysconf(_SC_PAGESIZE)(process.rs:55-58) =flare_eos::page_size()(eos/src/unix.rs:73-75; re-exported as helios/src/os.rs:8 and asflare_eos::*; eos is an unconditional dependency, helios/Cargo.toml:34).getrlimit(RLIMIT_NOFILE)(process.rs:68-77, 10 lines + SAFETY comment) duplicates the call insideflare_eos::raise_open_file_limit(eos/src/unix.rs:138-165, doc: "Returns the resulting soft limit when getrlimit succeeds");raise_open_file_limit(0)returns the current soft limit without calling setrlimit (unix.rs:144-147)./proc/self/fdcount (process.rs:65-67) is character-for-characteropen_descriptors()at helios/src/runtime_core/protection.rs:291-302 (behind the runtime-core feature, so the shared home is eos, which already owns the platform split). Two copies now exist with two return conventions. Fix: callflare_eos::page_size(); add oneopen_file_limit()besideraise_open_file_limit(or useraise_open_file_limit(0)); moveopen_descriptors()into eos and call it from bothprotection.rsand the renderer; leave only/proc/self/statand the/proc/statbtime parse inprocess.rs(no existing Rust reader for those two — genuinely new). Deletes ~25 lines, twounsafeblocks and one duplicate.
S6. Description accuracy (mechanical, cheap, no code):
- "nothing about serving changes": the change adds a monotonic clock read plus a lane loop per submitted step (runtime.rs:2187-2203), two stores per committed token (runtime.rs:1774-1775), and blocking procfs reads on every text scrape (server.rs:709 → process.rs:52-133: /proc/self/stat, the whole of /proc/stat just to find
btime, read_dir /proc/self/fd, two sysconf, one getrlimit). Say "no change to serving output", and list the per-step and per-scrape cost as known and unmeasured (reading all of /proc/stat forbtimeis avoidable). - The live scrape is under-explained: "counts gained 5 … and 6 for the first-response histogram" over a window that includes the agent session's own traffic, with the sixth TTFR observation unattributed and none of the sums tied to an individual request. Restate it as a smoke check and say plainly that the measured tree is the fork commit 5ffe4d54 plus this change, not
main(which the description does disclose, but the sums read as branch numbers). - "CI covers the first two": head ebecef1 has no checks. The workflow does build and test Windows and the full helios suite (.github/workflows/native-serving.yml:20-21, 63-68), so name the job — otherwise the sentence overstates. (Do not turn this into a blocker; the claim is about configuration, and it is one sentence.)
- Authorization (charter): "What gets merged" requires a maintainer request, roadmap item, reproducible bug, measured performance/memory issue, or bad docs; AGENTS.md:165-169 and :201-202 say an explicit maintainer request authorizes work, and #536 is an outside request framed as dashboard parity with vLLM, which the charter lists as a competitor, not a compatibility target. Also the names do not match vLLM's (
vllm:e2e_request_latency_secondsetc.), so "parity" is not literally achieved. Ask for a maintainer decision recorded on #536, or reframe around the defect the metrics remove (tail latency, queue delay, prefill time and decode rate are unobservable from a scrape), which the charter accepts.
#4 [high] Subtract / Simplify (~130 of +545 lines)
Headline: could remove roughly 130 of the +545 added lines, about 100 of them inside the one new file, with no behaviour lost. Nothing in the request-histogram core should be cut (see "keep" below).
- process.rs fallbacks and the kernel-asserting test (~55 of the file's 184 lines).
- Six
if let (Some(..), Some(..))blocks (process.rs:79-132) plus-> Optionplumbing inparse_btime(34-40) guard sources that cannot fail on Linux: /proc/self/stat, /proc/stat, /proc/self/fd are kernel-provided for the calling process andgetrlimit(RLIMIT_NOFILE)cannot fail for a valid resource. The module doc (1-6) elevates this to "a scrape never fails and never panics", which nothing requires; AGENTS.md:188-193 asks for a concrete requirement for exactly this kind of fallback layer, and the repo's own precedent defaults the page size once (eos/src/unix.rs:74). - Smaller shape: one
let Some(stat) = read + parse else { return },page_size()from eos (nosysconf, nounsafe),open_file_limit()/open_descriptors()from eos (see Should fix S5), and keep only the/procread fallbacks. Collapses fiveif letcombinations to two and the doc comment to one sentence. render_reports_process_memory_descriptors_and_start_time(process.rs:157-183, ~25 lines) asserts live kernel values (resident > 0,virtual >= resident,max_fds >= open_fds, start within the last hour) and the presence of six# TYPElines: it fails only if the host kernel is broken, and the end-to-end scrape check already exists at phase_tests.rs:5377-5388. Keepparse_stat_reads_fields_after_a_parenthesized_command_with_a_paren(148-155), which tests the one non-obvious parser.
-
The new
Histogram<N>did not replace what it duplicates (~40 lines).Buckets/Histogram(metrics.rs:212-298) is exactly the machinery already hand-rolled for the three host-cache cost histograms:HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS(200-210), the parallel arrays plushost_cost_sums(382-385), the.position(..).unwrap()bucket loop inhost_lookup_cost(670-692) and the 37-line render loop (1029-1065). Leaving both means three bucket encodings (u64::MAX sentinel vs f64::INFINITY vs milliseconds), three_count/_sumorders, and an uncheckedunwrap()(689) that the newobservealready avoids (unwrap_or(N-1), 268) — a fourth copy now has a template to follow. Fix: express the three host histograms asHistogram<8>overBuckets<8>; delete the two constants,host_cost_sums, the zip/position loop (threeobservecalls remain) and the 37-line render loop (threerendercalls remain). The existing testhost_outcomes_and_capacity_have_bounded_labels_and_cost_histograms(metrics.rs:1740-1796) reads rendered text and keeps passing if the labels stay; onlyflare_host_cache_*_sumchanges from a u64 integer to the same number divided byscale. Merge-order safe against #537 (different region of metrics.rs). -
One e2e observation point instead of two, and no
metrics_handle()clone (~6 lines). Every successful request yields exactly oneDelivery::Complete(http.rs:598; failuresreturnright afterDelivery::Failedat 574-578), so the sameif !count { …observe(REQUEST_SECONDS, admitted_at.elapsed()…) }is written once per delivery shape (http.rs:614-617 streaming, 631-635 non-streaming) and the streaming arm needslet metrics = state.model.metrics_handle();(603) only to satisfy the'staticclosure. Observe once just beforeyield Delivery::Complete(response)usingstate.model.metrics(); the timing is unchanged (that line is reached exactly when the two arms fire today, which the phase tests cover). This is also the one place where the cancelled-response guard for B1 can live, sinceencoder.tool_limit_reachedis in scope there. -
Fold the TTFR histogram into
Metrics(~12 lines), drop the duplicate render assertions and the non-Linux shim (~14 lines).
- Data and eligibility stay in
latency.rs; only the Prometheus rendering belongs with the other six families. Movingtime_to_first_response: Histogram<21>toMetricsand observing it through the handle http.rs already fetches deletes the extra struct field, the secondimpl FirstResponseSamplesblock (latency.rs:122-131), thepub(super) render_histogramAPI and server.rs:671 — and leaves one stated rule for where/metricstext is assembled instead of three. - phase_tests.rs:4428-4432 and 4461-4471 re-render metrics and re-check counts the route test (5377-5388) already checks through a real scrape. Keep the behavioural bit each test proves (a failed stream leaves e2e at 0 at 4428-4432; one offered body leaves it at 1 at 4461-4465) and drop the histogram re-render at 4466-4471.
- Non-Linux shim (process.rs:8-14 + the
let _ = text):#[cfg(target_os = "linux")]onpub(super) mod process;(metrics.rs:12) and onmetrics::process::render(&mut text)(server.rs:709) removes the wrapper and the discard, matching howprotection.rs:291-302andcore/cache.rsgate platform code. Worth doing precisely because the Windows build was not run here. - Optional scope:
process_virtual_memory_bytes(process.rs:88-96) andprocess_max_fds(124-132) are not in #536's table; virtual size is not actionable for a GPU server (it tracks CUDA/arena reservations). Dropping both removes ~18 lines plus two doc mentions and two test assertions. Keepprocess_max_fdsif the fd-budget path is the motivation; leave the call to the author.
Keep (do not cut): the five bucket lists (metrics.rs:219-241) are the #536 deliverable; RequestTimes and its two stamps (runtime.rs:1774-1775, 2187-2203) are the minimum for queue/prefill/decode, and preemption survival is free because parking moves Incoming whole (runtime.rs:2094-2121); request_completed as the single place that increments completed and observes (metrics.rs:452-480) is the right consolidation; entry point 543 (ms) is not needed.
#5 [high] Nits (9), rejected suggestions, conflict resolution
N1 process::metric (process.rs:42-49) duplicates metrics::metric (metrics.rs:1597-1602) minus the flare_ prefix, and does not inherit escape_prometheus_label (metrics.rs:1604-1615; harmless today because no process_* series takes a label). One emitter taking the full name, callers adding flare_, keeps one implementation and deletes the copy.
N2 parse_stat (process.rs:19-32) returns Some on any line containing ')', so a malformed/shifted line yields systematically wrong CPU/memory values instead of omitting them, contradicting the module doc's "omits only the metrics that depend on it". Practical impact nil for flared's own comm; one alternative is to require the expected field count. Nit only.
N3 process_open_fds (process.rs:65-67) counts the handle doing the counting, so it is +1 relative to Prometheus' client_golang, which excludes it. The HELP string says so ("including the directory read that counts them"), so it is a documented deviation — mention because #536's motivation is stock-process-dashboard parity.
N4 Worker::publish recomputes request.carried.prompt_tokens.unwrap_or(prompt_tokens) and carried.generated_tokens + generated (runtime.rs:1996-1997 and again at 2015-2019), while Worker::complete already hoists them (runtime.rs:1838-1840). Two locals make both call sites one shape (~4 lines).
N5 request_completed nests if let Some(first) = times.first_token_ns inside if let Some(scheduled) = times.first_scheduled_ns (metrics.rs:462-469); first_token_ns.is_some() implies first_scheduled_ns.is_some() because tokens are only committed for requests that went through reserve_and_pack, which stamps every lane (runtime.rs:2191-2203, 1774). Flattening to two siblings keeps the queue observation unconditional. Related: the test's second case constructs the impossible {first_scheduled_ns: None, first_token_ns: Some} state (metrics.rs:1684-1697); the realistic excluded shape is both None (a prompt-only/zero-token request). Make it that — but keep the case, it is the only evidence for the exclusion (see S1).
N6 last_token_ns versus the scheduler's accounting: RequestAccounting::last_output_ns is set in published_output when output is published (scheduler/policy.rs:270-275), not when a token is committed, so it cannot substitute; the field is justified. A one-line comment saying so would save the next reader the lookup, since the alternative looks tempting.
N7 Comment and prose weight: four doc comments cover three RequestTimes fields (metrics.rs:212-213, 243-244, 261-262, 300); the 261-262 rounding note defends an invariant the type already guarantees; runtime.rs:2189-2190 ("Stamp here rather than at submission…") only parses if the reader already knows reserve_and_pack has a second caller; process.rs:1-6 is three sentences for a forty-line module; docs/api.md:300-313 restates the # HELP strings sentence for sentence (keep the two facts a scrape cannot give: histograms are absent from format=json, and process_* is Linux-only).
N8 render_histogram sits in a second impl FirstResponseSamples block (latency.rs:122-131) instead of the block at 63-101; goes away entirely if the histogram moves into Metrics (Subtract item 3).
N9 PR-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. And the cherry-pick sentence should say plainly that the measured tree is ebecef1 rebased onto 5ffe4d54 (no other code change), since the counts are load-bearing.
Considered and rejected (recorded so the report does not ask for them):
- Simplicity's "drop
scale: f64and bucket on integer nanoseconds": thelelabels of a seconds histogram must print seconds (0.001), so a divisor on the exposed unit is load-bearing; removing the field only moves the conversion into the renderer. Not a saving. - Conventions/Architecture's "record e2e at runtime completion so transports agree" as the required fix: it is a real alternative but a bigger change than a doc clause plus a one-line guard; offered as the alternative under B1/S2, not as the ask.
- Subtractive's "delete the half of
request_histograms_bucket_completed_request_timingsthat buildsfirst_scheduled_ns: None": keep the case (reshape it per N5) — it is the only test of the exclusion that S1 asks to document. - Simplicity's "fold the runtime histograms into
[u64; N]arrays like the existing ones": this is the opposite direction to the migration that makes the file smaller; rejected in favour of converting the host histograms ontoHistogram<8>(Subtract item 2). - Architecture's suggested per-metric os readers in eos: matches S5; kept, but scoped to the three primitives that already exist (no new abstraction for the two /proc parses).
Reconciled conflicts and how:
- Docs disagreement between lenses (Prose said the "one observation per generation" sentence is the defect; Architecture added the
None-stamp complement) — merged into S1, with the fix as one sentence split by eligibility plus the "which families a prompt-only request skips" clause. - Convention lens wanted
docs/api.md:288fixed and the Prose lens wanted the same sentence; identical edit, one item (S3). - Architecture lens rated layering "should gate merge", Conventions rated it "no blocking"; resolved as Should fix, not a blocker, because the code is correct and the duplication is ~25 lines.
- Authorization: only the Architecture lens raised it. Kept as Should fix (not a blocker) with a cheap fix (record a maintainer decision or reframe around the observable defect), because the charter's tension is with the stated motivation, not the code.
#7 [high] Research summary
Both deliverables are written and delivered: the full report (Blockers, Should Fix, Subtract / Simplify, Nits, each finding with cited file:lines, the requested change and why) and the short summary report intended as the GitHub post (2 blockers, 5 should-fix, 4 subtract bullets with the "could remove ~130 of +545 added lines" estimate and top concrete removals, plus the Nits count of 9).
Verified in code rather than taken from the lens reports: the tool-limit e2e/cancelled divergence (http.rs:471-476, :526, :563-567, :598, :614-617, :631-635 vs runtime.rs:293-302 and the four cancelled increments), the per-family eligibility in Metrics::request_completed (metrics.rs:452-480) against the HELP strings and docs/api.md:305-313, the vision stamp before the GraphKind::Vision split (runtime.rs:2191-2203 vs :2208), the pre-existing eos/eos-backed primitives the new process.rs re-implements (eos/src/unix.rs:73-75, :138-165; runtime_core/protection.rs:291-302), the two hand-rolled host histograms the new Histogram did not replace (metrics.rs:200-210, 670-692, 1029-1065), the streaming vs non-streaming e2e asymmetry pinned by phase_tests.rs:4407-4473, and CI actually building/testing Windows and the full helios suite (.github/workflows/native-serving.yml:20-21 (not opened), 63-68) despite no checks on ebecef1.
Two corrections were made to the supplied lens findings, recorded on the scratchpad: the claim that Metrics::render is called by the terminal dashboard is false (dashboard.rs uses only snapshot()), so the per-scrape /proc cost is stated as per-/metrics-text-scrape only; and suggestions that would have expanded or misdirected work were rejected in favour of subtraction — dropping scale: f64, deleting the half of the metrics test that pins the generated_tokens>1 exclusion, folding the runtime histograms onto [u64; N] arrays, and requiring e2e at runtime completion as the only fix. Conflicts were resolved in favour of subtraction and the cheapest doc repairs; nothing in the change is blocking on size, and the request-histogram core is explicitly marked as not to be cut.
#8 [high] FINAL full report text (as delivered)
Full report — PR #548 "Add request latency histograms and process metrics"
Draft, head ebecef1, base main, 8 files, +545/−20, closes #536, author WynnD (Discord oystersmiles). No reviews, no CI checks on head. Right problem, right shape, not ready as-is. The core design needs no change: the five request histograms are observed in the single function that already increments flare_requests_completed_total (helios/src/server/metrics.rs:452-480), the two former direct fetch_add sites are now calls (runtime.rs:1841-1846, :1993-1998), no per-request storage is added, Snapshot/format=json is untouched, and nothing crosses the preparation/runtime boundary, adds a flag, or branches per model.
Blockers
-
flare_request_e2e_secondsincludes responses the runtime counts as cancelled — and the new docs say it cannot. Tool-limit path: http.rs:471-476 drops non-terminal events, :526 finishes the decoder withTermination::Cancelled, :563-567 callsgeneration.cancel(); the terminalFinishedstill passes, the loop reachesyield Delivery::Complete(response)(http.rs:598) and both delivery arms observe e2e guarded only by!count(http.rs:614-617, :631-635). The runtime counts that request inmetrics.cancelledviafinish_cancelled(runtime.rs:1317, :1338, :1360, :1407; :293-302) and never inrequest_completed, so it lands inflare_requests_cancelled_totalandflare_request_e2e_secondsbut in none of queue/prefill/decode/TPOT/prompt-tokens and not inflare_requests_completed_total. The cancel flag also races the natural finish, so membership is timing-dependent. docs/api.md:312-313 states the opposite absolutely; the description repeats it; AGENTS.md:182-186 applies. Change (either): skip the e2e observation whenencoder.tool_limit_reached(or thread the termination throughDelivery::Completeand observe only successful terminations); or narrow docs/api.md:312-313 to the five runtime histograms and say e2e measures every response delivered to the client. Add one test that drives a request past the parallel tool limit and asserts e2e count againstflare_requests_cancelled_total. Why: an operator reconcilingflare_request_e2e_seconds_countwithflare_requests_completed_totalcompares different populations while the page says they cannot differ. -
The Evidence section overstates coverage and does not reconcile; the change does touch the serving and scrape paths. "nothing about serving changes" is inaccurate: a monotonic clock read plus a lane loop per submitted step (runtime.rs:2187-2203), two stores per committed token (:1774-1775), and blocking procfs I/O per text scrape —
/proc/self/stat, the whole of/proc/statforbtime,read_dir("/proc/self/fd"), twosysconf, onegetrlimit(server.rs:709 → process.rs:52-133). The scrape numbers do not reconcile: "counts gained 5 for each runtime histogram and 6 for the first-response histogram" over a window that also served the agent session's requests; the prompt-token breakdown (le="64"+1,le="2048"+4) accounts for five runtime observations and leaves the sixth first-response observation unexplained; no sum is attributed to a request; the tree measured is fork commit 5ffe4d54 with this change cherry-picked, notmain. "CI covers the first two" is an expectation — head ebecef1 has no checks, though the workflow does build/test Windows and the full helios suite (.github/workflows/native-serving.yml:20-21, :63-68). Change (description only): say "no change to serving output" and list the per-step and per-scrape cost as known and unmeasured (reading all of /proc/stat forbtimeis avoidable); restate the live scrape as a smoke check with the population caveat explicit (6 TTFR vs 5 runtime observations, session traffic included, measured on 5ffe4d54 + this diff); keep the unit tests as the primary evidence; name the CI job or drop the sentence. Why: AGENTS.md:194-199 and docs/design-review.md:97-105 require honest evidence and disclosed limitations.
Should Fix
-
docs/api.md:305-313 — "one observation per completed generation" is false for decode and time-per-output-token.
request_completedobserves prompt tokens unconditionally (metrics.rs:460-461), queue only with a scheduled stamp, prefill only with a first token, decode/TPOT only withgenerated_tokens > 1(:462-479) — as the PR's own HELP strings already say (metrics.rs:1406-1418) while the neighbouring HELP strings do not (:1395-1404, :1419-1424). A prompt-only request appears in prompt tokens and the completed counter but in no timing family. Change: split the sentence by eligibility; add "cumulative since server start" (the "Totals count from server start" note at :329-330 sits beside a 60-second windowed median); replace "Request histograms observe the served response" (:300-301) with the two groups (HTTP-level response timing: e2e, TTFR; runtime per-request timing: queue, prefill, decode, per-token, prompt tokens). Keep the test at metrics.rs:1684-1697 that pins the exclusion. -
docs/api.md:301-304 and :288-289 — two one-clause edits. Streaming observes inside the SSE
filter_map(http.rs:614-617) so only if the client drains toDelivery::Complete; non-streaming observes in the handler (:631-635) before the body is polled — an asymmetry pinned by phase_tests.rs:4407-4434 vs :4437-4473 and not stated, though the adjacent TTFR sentence does say "once the client reads it". And "Counter and gauge names start withflare_" (:288-289) is contradicted by the sixprocess_*series documented at :315-318 (emitted at process.rs:78-132), which also breaks{__name__=~"flare_.*"}filters. Change: "counts each successful generation whose response the client reads to the end, from admission to delivery completion"; scope the prefix rule to runtime metrics, following the precedent at docs/api.md:334-336. -
flare_request_prefill_secondsincludes vision work.first_scheduled_nsis stamped over everystep.lanesentry (runtime.rs:2191-2203) before theif step.kind == GraphKind::Visionsplit at :2208, thoughstep.lane_kind(row).is_prefill()is available and used at :2281; the same page uses the narrower convention forprefill_tokens(docs/api.md:340). Change (cheapest): one phrase — "the request's first model step to its first committed generated token (including a vision step that runs first)"; alternatively narrow the stamp loop to prefill lanes. -
The new module hand-rolls OS primitives that already live in
eos/. AGENTS.md:20-21 and the charter's "Solve the right problem in the right place":libc::sysconf(_SC_PAGESIZE)(process.rs:55-58) isflare_eos::page_size()(eos/src/unix.rs:73-75, re-exported at helios/src/os.rs:8, unconditional dependency at helios/Cargo.toml:34);getrlimit(RLIMIT_NOFILE)(process.rs:68-77, 10 lines + SAFETY comment) duplicates the call insideflare_eos::raise_open_file_limit(eos/src/unix.rs:138-165), wheredesired = 0returns the soft limit unchanged (:144-147); the/proc/self/fdcount (process.rs:65-67) is character-for-characteropen_descriptors()at runtime_core/protection.rs:291-302, now in two places with two return conventions. Change: callflare_eos::page_size(), take the soft limit from eos, moveopen_descriptors()into eos and call it from both sites, leave only the/proc/self/statandbtimeparsing inprocess.rs. Deletes ~25 lines and twounsafeblocks. -
Authorization rests on an outside request framed as vLLM parity. Charter "What gets merged" accepts a maintainer request, roadmap item, reproducible bug, measured performance/memory issue, or bad docs; AGENTS.md:165-169 and :201-202 make an explicit maintainer request the authorization; #536 is an outside request to port vLLM dashboards, vLLM being a listed competitor rather than a compatibility target. The names do not match vLLM's either, so "parity" is not literally achieved. Change: record a maintainer decision on #536, or reframe around the defect the metrics remove (tail latency, queue delay, prefill time and decode rate are unobservable from a scrape). Cheap; only the stated motivation is contested.
Subtract / Simplify
Could remove ~130 of the +545 added lines — about 100 of them inside the one new file — with no behaviour lost. Nothing in the request-histogram core should be cut.
- metrics/process.rs: six fallbacks for sources that cannot fail, plus a test that asserts the kernel (~55 of 184 lines).
/proc/self/stat,/proc/stat,/proc/self/fdare kernel-provided andgetrlimit(RLIMIT_NOFILE)cannot fail for a valid resource, yetrender_linuxthreads sixif let (Some, Some)blocks (process.rs:79-132) plusOptionplumbing inparse_btime(:34-40), justified by a module doc promising "a scrape never fails" (:1-6) — the fallback layer AGENTS.md:188-193 rejects without a concrete requirement; the repo's own precedent defaults the page size once (eos/src/unix.rs:74). Onelet Some(stat) = … else { return }, page size and fd limit from eos, and only the/procread fallbacks collapse five combinations to two and the doc comment to a sentence. Droprender_reports_process_memory_descriptors_and_start_time(:157-183): it fails only if the host kernel is broken, and the end-to-end scrape check already exists at phase_tests.rs:5377-5388. Keepparse_stat_reads_fields_after_a_parenthesized_command_with_a_paren(:148-155). - The new
Histogram<N>was added beside the hand-rolled histograms it duplicates (~40 lines).Buckets/Histogram(metrics.rs:212-298) is what the three host-cache cost histograms already hand-roll:HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS(:200-210), the parallel arrays andhost_cost_sums(:382-385), the.position(..).unwrap()loop inhost_lookup_cost(:670-692) and the 37-line render loop (:1029-1065). AsHistogram<8>overBuckets<8>those delete two constants,host_cost_sums, the zip/position loop (threeobservecalls remain) and the whole render loop (threerendercalls remain);host_outcomes_and_capacity_have_bounded_labels_and_cost_histograms(:1740-1796) reads rendered text and keeps passing if labels stay, with onlyflare_host_cache_*_sumchanging from a truncated integer to the same number divided byscale. Also removes the third bucket encoding, the third_count/_sumorder and the uncheckedunwrap()at :689. Merge-order safe against #537 (different region of metrics.rs). - One e2e observation point, and the TTFR histogram belongs with the other six (~18 lines). Every successful request yields exactly one
Delivery::Complete(http.rs:598; failuresreturnafterDelivery::Failedat :574-578), so the sameif !count { …observe(REQUEST_SECONDS, admitted_at.elapsed()…) }is written twice (:614-617, :631-635) and the streaming arm needsstate.model.metrics_handle()(:603) only for the'staticclosure. Observe once before theyield;encoder.tool_limit_reachedis in scope there, so the Blocker-1 guard goes there too. Movingtime_to_first_responseontoMetricsdeletes the extra struct field, the secondimpl FirstResponseSamplesblock (latency.rs:122-131),render_histogramand server.rs:671, leaving one assembly rule instead of three; then phase_tests.rs:4466-4471 and the duplicate route check at :4428-4432 go, keeping the behavioural assertions (0 after a failed stream, 1 after one offered body). - Smaller:
#[cfg(target_os = "linux")]onpub(super) mod process;(metrics.rs:12) and on the call (server.rs:709) deletes the non-Linux shim andlet _ = text(process.rs:8-14), matching protection.rs:291-302 and core/cache.rs gating — worth doing since Windows was not built here. Optionally dropprocess_virtual_memory_bytes(process.rs:88-96) andprocess_max_fds(:124-132), neither in #536's table, for ~18 lines plus two doc mentions and two test assertions (keepprocess_max_fdsif the fd-budget path motivates it).
Keep: the five bucket lists (metrics.rs:219-241); RequestTimes and its two stamps (runtime.rs:1774-1775, :2187-2203) — the minimum for queue/prefill/decode, preemption survival free because parking moves Incoming whole (:2094-2121); request_completed as the single place that increments and observes.
Nits (9)
process::metric(process.rs:42-49) duplicatesmetrics::metric(metrics.rs:1597-1602) minus theflare_prefix and does not inheritescape_prometheus_label(metrics.rs:1604-1615); one emitter taking the full name deletes the copy.parse_stat(process.rs:19-32) returnsSomefor any line containing), so a shifted line yields wrong values instead of omitting them, contradicting the module doc; require the expected field count.process_open_fds(process.rs:65-67) counts the directory read that counts it (+1 vs Prometheus' client_golang); documented in the HELP, so a deviation, not a defect — noted because #536's motive is stock dashboard parity.Worker::publishrecomputescarried.prompt_tokens.unwrap_or(prompt_tokens)andcarried.generated_tokens + generated(runtime.rs:1993-1998 and again :2015-2019) whileWorker::completehoists them (:1838-1840); two locals, ~4 lines.request_completednestsif let Some(first) = times.first_token_nsinsideif let Some(scheduled), a state that cannot occur (metrics.rs:462-469; tokens are only committed for requests stamped in reserve_and_pack, runtime.rs:2191-2203, :1774) — flatten to siblings; and reshape the test's impossible{first_scheduled_ns: None, first_token_ns: Some}case (metrics.rs:1684-1697) into the realistic both-Noneprompt-only request, keeping the case because it is the only evidence for the exclusion.last_token_nscannot come fromRequestAccounting::last_output_ns, which is set on publication (scheduler/policy.rs:270-275), not token commitment; one comment would save the next reader the lookup.- Comment/prose weight: four doc comments for three
RequestTimesfields (metrics.rs:212-213, :243-244, :261-262, :300), the :261-262 rounding note, runtime.rs:2189-2190, process.rs:1-6, and docs/api.md:300-313 restating the HELP strings (keep only "histograms are absent from format=json" and "process_* is Linux-only"). render_histogramsits in a secondimpl FirstResponseSamplesblock (latency.rs:122-131) instead of the block at :63-101; goes away with the Subtract item.- Description wording: "The existing first-response sampler observes … its median gauge and 60-second window are unchanged" — make the sampler the subject; and the cherry-pick sentence should say the measured tree is ebecef1 rebased onto 5ffe4d54 with no other code change.
Corrections to lens input (do not repeat their errors)
- The claim that
Metrics::renderis also called by the terminal dashboard is FALSE: dashboard.rs:128-146 uses onlysnapshot()andpersistent_worker_snapshot(). The per-scrape procfs cost is per/metricstext scrape only. - Rejected suggestions: dropping
scale: f64(thelelabels must print seconds, so the divisor is load-bearing); deleting the half ofrequest_histograms_bucket_completed_request_timingsthat pins thegenerated_tokens > 1exclusion (it is the only evidence for the doc fix); folding the runtime histograms onto[u64; N]arrays (opposite direction to the migration that shrinks the file); making "record e2e at runtime completion" the required fix (bigger change; offered only as the alternative under Blocker 1).
#9 [high] FINAL summary report text (GitHub post)
Not ready to merge as-is: two cheap blockers, after which the diff can shrink by about a quarter. The design is right — fixed-bound histograms recorded where flare_requests_completed_total is already incremented, no per-request storage, no new JSON fields, no flags — and nothing here asks you to add code.
Blockers
flare_request_e2e_secondsrecords responses the runtime counts as cancelled. On the parallel-tool-limit path (http.rs:471-476, :526, :563-567) the terminal event still reachesDelivery::Complete(:598) and both arms observe e2e (:614-617, :631-635), while the runtime only incrementscancelledand callsfinish_cancelled(runtime.rs:293-302, :1317/:1338/:1360/:1407). The request appears inflare_request_e2e_secondsandflare_requests_cancelled_totalbut in no other request histogram, and the cancel flag races the natural finish so membership is timing-dependent. Fix: guard on!encoder.tool_limit_reached, or narrow docs/api.md:312-313 to the five runtime histograms; add one tool-limit test asserting e2e count vs cancelled total.- Evidence overstates and does not reconcile. "Nothing about serving changes" is inaccurate: a clock read plus a lane loop per submitted step (runtime.rs:2187-2203), two stores per committed token (:1774-1775), and blocking procfs reads per text scrape (server.rs:709 → process.rs:52-133, including all of /proc/stat for
btime). The scrape deltas give 6 TTFR against 5 runtime observations, include the agent session's traffic, attribute no sum to a request, and come from 5ffe4d54 + this diff, notmain; "CI covers the first two" is an expectation since ebecef1 has no checks. Fix (description only): state the per-step and per-scrape cost as known and unmeasured, restate the scrape as a smoke check with the population caveat, name the CI job or drop that sentence.
Should fix
- docs/api.md:305-313: split by eligibility — decode and time-per-output-token only with at least two generated tokens (metrics.rs:470-479; the HELP strings at :1406-1418 already say so), so a prompt-only request appears in prompt tokens and the completed counter only. Add "cumulative since server start" and name the two groups instead of "observe the served response".
- docs/api.md:301-304 and :288-289, two one-clause edits: e2e ends at delivery and, for streams, only if the client drains the body (http.rs:614-617 vs :631-635, pinned by phase_tests.rs:4407-4434) — say so as the TTFR sentence does; and "Counter and gauge names start with
flare_" is contradicted by the sixprocess_*series documented at :315-318. flare_request_prefill_secondsabsorbs vision:first_scheduled_nsis stamped before theGraphKind::Visionsplit (runtime.rs:2191-2203 vs :2208). One phrase in the doc — "the first model step to the first committed token, including a vision step that runs first" — or narrow the stamp to prefill lanes.- Move the OS reads into eos/ (AGENTS.md:20-21):
_SC_PAGESIZEisflare_eos::page_size()(eos/src/unix.rs:73-75),RLIMIT_NOFILEis the call insideraise_open_file_limit(:138-165,desired = 0), and the/proc/self/fdcount is alreadyopen_descriptors()(runtime_core/protection.rs:291-302). Leave only the /proc/self/stat andbtimeparsing in process.rs. - Record a maintainer decision on #536, or reframe the description around the defect (tail latency, queue delay, prefill time and decode rate are unobservable from a scrape). A vLLM-parity request is a listed competitor, not an authorization under the charter's "What gets merged".
Subtract / Simplify — could remove ~130 of +545 added lines (~100 inside process.rs)
- process.rs: six
if let (Some, Some)fallbacks for sources that cannot fail (:79-132) plus the "never fails" module doc, and a test asserting live kernel values (:157-183). Collapse to one early return with eos getters, keep only theparse_stattest — ~55 lines; the route test at phase_tests.rs:5377-5388 already covers the end-to-end scrape. - Convert the three host-cache histograms onto
Histogram<8>/Buckets<8>: deletesHOST_*_BUCKETS(metrics.rs:200-210),host_cost_sums, the.position(..).unwrap()loop (:670-692) and the 37-line render loop (:1029-1065) — ~40 lines. Otherwise the file keeps three bucket encodings, three_count/_sumorders and one uncheckedunwrap()the new type already avoids. - Observe e2e once before
yield Delivery::Complete, and movetime_to_first_responseontoMetrics: removes the duplicated observation, themetrics_handle()clone, the secondimplblock (latency.rs:122-131),render_histogram, server.rs:671 and the duplicate assertions at phase_tests.rs:4428-4471 — ~18 lines, and gives /metrics one assembly rule instead of three. #[cfg(target_os = "linux")]on the module (metrics.rs:12) and the call (server.rs:709) instead of thelet _ = textshim; optionally dropprocess_virtual_memory_bytesandprocess_max_fds, which #536's table does not list.
Nits: 9 — duplicate process::metric emitter, parse_stat accepting any line with ), process_open_fds counting itself (+1 vs Prometheus), two expressions in Worker::publish not hoisted as complete does, the impossible {None, Some} test state, the missing note on why last_output_ns cannot substitute for last_token_ns, comment/prose weight, the separate impl block, and two description wording fixes. All listed with file:line in the case file.
#6 [medium] Corrections to notes 4 and the dashboard claim
Two corrections to earlier notes:
- Entry 4 ends with a stray fragment ("entry point 543 (ms) is not needed") — ignore it; no such item exists.
- Architecture's evidence claim that
Metrics::render"is also called by the terminal dashboard" is WRONG: helios/src/server/dashboard.rs uses onlymetrics.snapshot(...)andpersistent_worker_snapshot()(dashboard.rs:128-146), neverrender(). The only production caller of the text render is the/metricsroute (server.rs:660), plus tests (metrics.rs, phase_tests.rs, runtime.rs). So the per-scrape procfs cost should be stated as per-/metrics-text-scrape only — do not repeat the dashboard claim in the report.