PR #548 — Add request latency histograms and process metrics (case file)
Repository: NVIDIA/hyperflare-inference · PR: https://github.com/NVIDIA/hyperflare-inference/pull/548
Author: WynnD (git name Wynn Drahorad; Discord oystersmiles; GitHub association NONE)
State: draft, base main, head ebecef1, branched from f377dc8, 8 files +545 / −20, no labels, no reviews, no CI checks on the head commit, opened and last updated 2026-11-26. Closes #536.
Key findings
- The queue histogram does not measure what the driving issue asked for. Issue #536 asks for
flare_request_queue_seconds= "admission to first scheduled step"; the PR measures runtime arrival → first scheduled step:Incoming.arrival_nsis set insideModelRuntime::schedule(helios/src/server/runtime.rs:901) and handed to the scheduler atruntime.rs:1471, so HTTP ingress, tokenization and framework preparation are excluded.docs/api.md(PR head, lines 305-307) says "from model-scheduler arrival", but the PR description names neither endpoint, and e2e/TTFR by contrast start at HTTP admission (AdmittedAt,helios/src/server.rs:828, read athttp.rs:127). Anyone porting a vLLM dashboard can mis-map this series. - Undeclared asymmetry between the two HTTP histograms.
flare_time_to_first_response_secondsis recorded only when the client actually polls the body (FirstResponse::output,http.rs:607/:638), whileflare_request_e2e_secondsis recorded as soon as the handler produces a completed response even if the body is dropped (http.rs:614-617streaming,:631-632non-streaming). The phase testfirst_response_http_nonstream_records_only_when_completed_body_is_offered(phase_tests.rs:4436-4473) pins e2e count = 1 regardless of polling while TTFR followspoll_body, andfirst_response_http_stream_excludes_pretext_failures_and_unpolled_bodies(phase_tests.rs:4406-4434) pins e2e = 0 on failure. So e2e measures server-side handling, not delivery. - Silent doc repair, plus a new doc inconsistency left standing. The docs hunk adds the already-shipped
flare_host_cache_retirement_secondsto a list that onmainstill reads "The only histograms describe host prefix-store lookups…" (docs/api.md:290-292on main vs:296-300at PR head) — an undeclared fix. Conversely the PR adds unprefixedprocess_*while leaving "Counter and gauge names start withflare_" (docs/api.md:288-289) unamended. - Process metrics exist only on Linux, but Windows is a supported serving target.
metrics/process.rsis hand-rolled procfs/getrlimitcode withrender()a no-op outside Linux (process.rs:9-14);libcis already an unconditional dependency offlare-helios(helios/Cargo.toml:50), so there is no Cargo change, but the description's motivation ("generic Prometheus process dashboards have noprocess_*series") is resolved only on Linux. The Windows matrix (native-servingbuilds and tests onwindows-2022) would report nothing there. Documented ("Other platforms omit them",docs/api.md:315-318) but easy to miss. - Evidence is partial and no CI has run. Claimed:
server::runtime::phase_tests109 passed,server::metrics::20 passed — two module subsets. Explicitly unrun: the Windows build, the full helios suite, andmessages_image_hints_end_after_expansion_for_text_and_segmented_templates. The author writes "CI covers the first two", which refers to whatnative-servingwould do (ubuntu-24.04 + windows-2022,.github/workflows/native-serving.yml:56-68(not opened)), not to a run: no check has executed onebecef1. The live scrape is one two-GPU DeepSeek-V4.1-Flash instance whose deltas include the serving instance's own agent-session traffic — a self-declared confound ("Counts gained 5 for each runtime histogram and 6 for the first-response histogram" against three named requests). - Everything in the cluster is under a day old and nobody with merge rights has engaged. #536 and #537 were filed the same morning (2026-11-26, 09:03 / 09:07) by Napuh, an account with no merged work in the 180-day window; #548 and #549 were opened the same day by WynnD, also with no merged work. Zero comments, reviews or reactions on any of the four; the only adjacent voice is #541's author jere357. Demand is therefore one requester wide and <1 day old as recorded locally, though
docs/TODO.txt:110-124already carries a standing TODO to measure "request p99" and "request latency measurements". - Two histogram implementations now coexist in one file. The existing host-cache histograms (
flare_host_cache_missing_tokens,estimated_transfer_ns,estimated_prefill_ns,retirement_seconds) keep their[AtomicU64; 8]arrays andflare_selene::RETIREMENT_LATENCY_MSbounds (metrics.rs:851-890); the new genericBuckets/Histogram<N>(metrics.rs:214-298) does not absorb them, and the diff does not touch that region. metrics.rshas three open PRs in flight. #548, #549 (same author, same day) and #542 (FujitsuPolycom), plus #334 touching the file; the description reasons only about #549's overlap. Nothing onmainconflicts — no default-branch commit sincef377dc8touches any file this PR changes.
The change
What it does in plain terms: /metrics gains fixed-bucket distributions for how long a request waited, how long prefill and decode took, how long each output token took, how large prompts are, how long the whole HTTP response took and how long until the first answer text appeared; plus the six standard process_* series that Prometheus process dashboards expect. All of it is always on and rendered into the Prometheus text only; the JSON snapshot is unchanged.
File by file (PR #548, head ebecef1):
helios/src/server/metrics.rs(+228) — new genericBuckets<const N>/Histogram<const N>(per-bucketAtomicU64plus a nanosecondsum,metrics.rs:214-298), bucket setsREQUEST_SECONDS(21 bounds, 1 ms … +Inf,:219-225),TOKEN_SECONDS(19 bounds,:227-233),PROMPT_TOKENS(21 bounds, 1 … +Inf,:235-241);RequestTimes(:300-306); six histogram fields onMetrics(:327-332);Metrics::request_completed(:452-480); the render block (:1391-1421); one new test.helios/src/server/runtime.rs(+38/−8) —Incoming.times(:190-194), surviving preemption because parking movesIncominginto the parked list;Worker::completestampsfirst_token_ns/last_token_ns(diff hunk at ~:1771-1778); both formermetrics.completed.fetch_addsites replaced withmetrics.request_completed(diff hunks ~:1834-1852and ~:1990-2000);Worker::reserve_and_packstampsfirst_scheduled_nsfor every lane afterscheduler.commit(diff hunk ~:2186-2203).helios/src/server/http.rs(+6/−1) —state.model.metrics_handle()captured for the stream arm; e2e observed inDelivery::Completefor both arms, gatedif !countwherecountis the/v1/messages/count_tokenspath (http.rs:131).helios/src/server/latency.rs(+27/−8) —FirstResponseSamplestuple struct becomes{window: Mutex<Samples>, histogram: Histogram<21>};FirstResponse::outputalso observes TTFR;render_histogramadded. Median gauge and 60 s window unchanged.helios/src/server/metrics/process.rs(new, +184) — Linux procfs reader; two tests.helios/src/server.rs(+2) —state.first_response.render_histogram(&mut text)andmetrics::process::render(&mut text)in the/metricstext handler.helios/src/server/runtime/phase_tests.rs(+35) — three existing tests extended plus the fixture constructor.docs/api.md(+25/−3) — new prose paragraphs for host-prefix and request histograms and for theprocess_*series.
Verified semantics of each request histogram (Metrics::request_completed, metrics.rs:452-480):
- Prompt tokens =
carried.prompt_tokens.unwrap_or(live.prompt_tokens), i.e. the original prompt length carried across preemption, so it agrees with the per-responseusage.prompt_tokens. Observed for every completed request (no gating). - Queue observed only when
first_scheduled_nsis set, measuredscheduled − arrival_ns.first_scheduled_nsis stamped inreserve_and_packafterscheduler.commit, first-write-wins, so a request planned but never committed gets no queue observation. - Prefill observed only when both stamps exist,
first_token − scheduled. - Decode and time-per-output-token only when
generated_tokens > 1;time_per_output_tokenis integerdecode / (generated_tokens − 1), truncating to whole nanoseconds before bucketing — harmless at 19 buckets. - Both completion-counter increments live in
request_completed, and cancelled (runtime.rs:1317,1338,1360,1407) and failed (:330) paths do not observe, matching the description anddocs/api.md:312-313. Histogram::observeis a linear scan of bounds withOrdering::Relaxed;_sumis printed assum as f64 / 1e9(metrics.rs:291-296), which loses exactness only after ~104 days of accumulated request time in one counter.
The why
- Issue #536, "Metrics: add request latency histograms and process metrics for monitoring parity with vLLM" (Napuh, 2026-11-26 09:03, open, 0 comments, env v0.3.2
c0c4f79). It tables what is missing against vLLM (vllm:e2e_request_latency_seconds, queue time,time_per_output_token/inter-token latency, prefill duration, decode duration, TTFT,vllm:request_prompt_tokens, and theprocess_*series) and states the motivation plainly: the existing median gauge cannot give P95/P99, cannot be computed over other windows, and cannot be aggregated across instances, whereas histograms allowhistogram_quantile()over any window and tail-latency alerts. It proposes exactly the names this PR implements and asks forflare_first_response_median_secondsto be kept (it is). - Where the PR departs from the ask: #536 wanted queue = "admission to first scheduled step"; the PR starts at runtime arrival. #536 did not list
process_virtual_memory_bytes(the PR adds it). #536's Grafana/SLO migration framing is picked up by #541. - Sibling issue #537 (Napuh, 2026-11-26 09:07, open, 0 comments):
vllm:kv_cache_usage_perccannot be computed because pages pinned by active requests still count asflare_cached_kv_pages; it reports three attempted bounds on the same two-GPU load (1 − free/totalhigh even idle;1 − (free+cached+snapshot_backing)/total~0 %;1 − (free+snapshot_backing)/total~16 %; vLLM ~9 %) and proposesflare_request_kv_pagesor splitting cached into pinned/idle. Closed by #549, not by #548, but referenced in this PR's description. - How old and how widely wanted: by the local record, under a day and one requester. No older issue asks for request histograms; searches for
histogram,p95/p99,vLLM parity,time to first tokenreturn only #536/#548/#549/#541. Two pre-existing adjacent signals: issue #78 (open, DS4.1 Flash disk Engram) asks in passing whether "per-gather latency/miss-count histograms and explicit metric scope/rank labels" would be useful (different subsystem), anddocs/TODO.txt:110-124already tracks "Measure cross-host rank handoff … request p99 …" and "Qualify retained graph costs … request latency measurements; measure GPU replay, queueing, and host planning separately" — the closest thing to a standing project want in this area.
Related work
- #549 "Report KV pages held by active requests" (WynnD, 2026-11-26 20:24, open) — sibling PR by the same author, closes #537, also edits
helios/src/server/metrics.rsanddocs/api.mdpluscache.rs(not opened)/scheduler.rs/tests. Both descriptions claim the hunks are disjoint and "merge in either order"; verified plausible (#549 adds gauges nearcached_pages/SchedulerStatsand its own docs paragraph; #548 adds histograms besidecompletedand its own). Effectively a two-PR series closing #536 + #537 together. - #541 "Add a Prometheus and Grafana monitoring example" (jere357, 2026-11-26 16:47, updated 19:21, open) — a docker-compose Prometheus+Grafana example under
examples/monitoring/; its auto-review explicitly notes that "The only in-repo signal of Grafana interest is issue #536 (latency histograms, which Flare does not yet export)". This is the consumer-side motivation, but its dashboards do not query the new series (they predate the PR and its reviews flag missing/differently-named panels); a review retitled DEPTH panels as belonging "with #536/#537". - #507 "Add persistent worker counter schema, Prometheus metrics, /v1/worker telemetry, launch dashboard view…" (merged, f646bebc 2026-11-24, Luke Alonso) — the last metrics-area commit and the function the new code sits beside; also the source of the fork-base cherry-pick conflict the author describes. On
mainit is present and untouched, so the merge is a clean add. - #542 (FujitsuPolycom, open) and #334 (javieratomic, open) also touch
helios/src/server/metrics.rs— a three-way (four-way counting #549) textual-overlap queue that whichever lands first will shape. - No competing or superseding implementation of request histograms exists: searching
histogram/prometheus/metricsamong items returns only #536, #548, #549, #541. - Prior art left unfactored: the four host-cache histograms in the same file (
metrics.rs:851-890) keep their own[AtomicU64; 8]arrays andflare_selene::RETIREMENT_LATENCY_MSbounds and divide by 1000 at render time; the diff does not migrate them, so the file holds two histogram implementations.
Recent activity
- No default-branch commit since the branch point
f377dc8touches any file this PR changes, so the change builds on nothing in flight and reverses nothing. Recenthelios/srccommits (#538 cold pure-prefill, #532 16-SM alignment, #527 Latent576 codec, #525 kv-codec parallel, #529 GB300 PCI id, #523 kv-codec verify, #522 GPU confidence calibration, #504 KV compression) and recentdocs/commits (#545, #543, #538, #508, #531) are unrelated to metrics, latency or/metrics. - The nearest prior commit is #507 (
f646bebc, 2026-11-24): the persistent-worker counter schema and Prometheus surface the new histograms sit next to. The change extends that work rather than conflicting with it. - The
process_*series is new surface in the/metricshandler (server.rs:709); no prior or in-flight work in the repo provides it.
People
- WynnD (Wynn Drahorad, Discord
oystersmiles): first contribution; GitHub association with the repo NONE; 0 merged, 0 closed, 1 other open PR (#549, same day) in the last 180 days. Both PRs close issues filed that morning. - Napuh (issue filer of #536 and #537): also no merged work in the 180-day window; both issues carry
Environment: hyperflare-inference v0.3.2 (c0c4f79)and zero comments. Demand and supply appeared within ~12 hours from two accounts with no prior merged history. - jere357 (Discord
cropinky): #541, the Grafana consumer; has not commented on #548. - Who usually works in these files:
helios/srcin the last 180 days is Luke Alonso (207), Martin Vit (47), yatesdr (47);docs/Luke Alonso (367), Martin Vit (52), yatesdr (47). Insidemetrics.rs, yatesdr owns the host-cache/selene counters (#400, #415, #429, #358, #168, #141, #92), Luke Alonso the persistent-worker schema (#507) anddocs/api.md§Health and metrics, Martin Vit #504/#479/#298, jasonc orbit/agent sampling, Eugene Rakhmatulin KV capacity gauges. None of them has engaged with #548. - Charter-named priority contributors
@voipmonitor,@original-el8,@lukealonsoare not authors of #548 or #541.
Community
Nothing found. pr_comments on #548 returns "No comments" — no reviews, inline comments or reactions; #536 and #537 each show "Discussion (0)". The only links are structural: #536 closes-via #548, #536 mentions #541 and #549, #537 closes-via #549 and mentions #548/#541. Two authors, one issue filer, no maintainer in any thread.
Project fit
Aligned:
- Observability-only, no per-model branch: the code is scheduler/runtime-level, which sits with the charter's "keep the runtime small and model-agnostic" rather than against it.
- No new dependency:
libcis already unconditional (helios/Cargo.toml:50), which fits the project's pin-everything/no-new-crates preference; the alternative (prometheuscrate's process collector) was avoided. - The description follows
AGENTS.md:72-112's mandatory four-part shape (why / what changed / claimed result / evidence), states what was not run, and carries the requiredDiscord:line. - The project already ships a rich
flare_*surface, a terminal dashboard and a documented/metricscontract, so metrics work is established practice.
In tension:
- Charter "What gets merged": "PRs that address a maintainer request, a roadmap item, a reproducible bug, a measured performance/memory issue, or bad docs", and
AGENTS.md:165-169requires an explicit maintainer request, a demonstrated defect, a measured performance/memory problem, or inaccurate documentation — "hypothetical future consumers … alone do not establish a need". #548 addresses a non-maintainer issue; no maintainer has commented anywhere in the cluster; the only in-repo consumer (#541) is itself unmerged. - The motivating framing — "monitoring parity with vLLM", moving existing Grafana dashboards and SLO alerts — leans toward production monitoring, while the charter's Non-Goals include broad production coverage and general operational tooling and the project describes itself as a focused research prototype rather than a general-purpose production server.
- The charter's "smallest footprint … or a way to solve it without new code at all" invites a reviewer to ask whether ~184 lines of hand-written procfs code is the smallest option; the counter-argument is that the dependency-free choice matches "pin everything".
AGENTS.md:52-60prefers recording unrun checks and unresolved items indocs/TODO.txt; the Linux-only omission is instead documented as designed behavior indocs/api.md, which is defensible.
Claims and evidence
What the description claims, and what backs it:
| Claim | Backing |
|---|---|
server::runtime::phase_tests: 109 passed |
Author-reported run on Linux x86_64, release, --features runtime-core,server; named tests (reasoning_budget_cuts_… with queue/prefill/prompt counts each 1 after park+readmit; the two first_response_http_* tests; metrics_route_serves_prometheus_or_json_without_the_api_key) are consistent with the test diffs |
server::metrics::: 20 passed |
Author-reported; includes request_histograms_bucket_completed_request_timings (metrics.rs:1654-1700 region), parse_stat_reads_fields_after_a_parenthesized_command_with_a_paren and render_reports_process_memory_descriptors_and_start_time (process.rs:148-183) — both present in the diff |
| Live scrape shows the series populated | One two-GPU DeepSeek-V4.1-Flash instance, repo Dockerfile, swapped into a llama-swap entry; deltas include the serving instance's own agent-session requests (self-declared), so counts (5 per runtime histogram, 6 for TTFR) exceed the three named requests; prompt-token buckets are used to attribute the extra observations (le="64" +1 = the 36-token prompt; le="2048" +4 = two 1831-token prompts plus two session requests). Sums reported: queue 0.169 s, prefill 0.301 s, decode 19.64 s, time-per-output-token 0.039 s, e2e 20.26 s. Final scrape: resident memory 67 666 030 592 B, open fds 276, max fds 1024. |
| Nothing about serving changes | Claimed; no benchmark, and the added cost is not measured or mentioned: one extra monotonic_ns() per completion and one per step per lane in reserve_and_pack, one or two Relaxed atomic adds plus a 21-entry linear scan per completed request, and ~63 AtomicU64 (~500 B) per Metrics instance. Implausible as a throughput risk, but unquantified. |
| CI covers the Windows build and full suite | The native-serving matrix does build+test helios with --features runtime-core,server on ubuntu-24.04 and windows-2022 and sets FLARE_TEST_TEMPLATE_DIR from tests/frontend/prepare_templates.py (not opened) (.github/workflows/native-serving.yml:28-31 (not opened),56-68) — but no check has run on ebecef1. |
| Merges in either order with #549 | Verified plausible from both diffs (disjoint regions of metrics.rs and docs/api.md); not independently tested. |
| The cherry-pick conflict story | Concerns reproducing the live scrape on fork base 5ffe4d54, not the merge target; on main the #507 code is present and the diff neither removes nor relocates it. |
Not stated in the description at all: the queue histogram's start point; the e2e/TTFR polling asymmetry; the process_open_fds off-by-one (it counts the directory handle it opens — declared in the help string, process.rs:115-123); the permanent ~190-line growth of every /metrics response with no opt-out; the undeclared flare_host_cache_retirement_seconds doc fix; the two histogram implementations coexisting.
Reach
- Operators on Linux get the new distributions and the six
process_*series; generic Prometheus process dashboards start working there. Operators on Windows (a supported serving target;docs/windows.md(not opened),flare-winui, and thenative-servingWindows matrix) get noprocess_*series, so their dashboards stay empty. - No configuration, flag, default or CLI change: nothing to enable or disable; histograms are always recorded and always rendered, so scrape size grows by roughly 6 × (21 buckets + help/type/sum/count) ≈ 160 lines plus ~30 Linux lines, permanently.
- JSON consumers: nothing changes.
Metrics::snapshotgains no fields, and the/metricsJSON path (server.rs:645-659) still emits onlyfirst_response, input counters andpersistent_worker.docs/api.mdsays histograms are Prometheus-only, consistent with the description. - Docs: the new series are described in prose paragraphs above the field table (
docs/api.md:296-318) rather than added as rows; the table remains the field↔name map, so the new request series have no rows. #541's reviewer separately flagged that table for missing*_kv_tokensgauges andrequests_cancelled_total. - Compat: existing series and gauges unchanged, including
flare_first_response_median_secondsand its 60-second window.process_*is deliberately unprefixed to match the standard collector names, which contradicts the standing sentence "Counter and gauge names start withflare_" (docs/api.md:288-289) that the PR leaves unamended.
Process
- Draft, base
main, headebecef1, branched fromf377dc8; 8 files +545/−20; no labels; no reviewers; no reviews or inline comments; no CI checks on the head commit; opened and updated 2026-11-26 (under a day old when examined). - The description meets the repo's mandatory four-part shape and gives the required Discord handle; both issues carry Discord handles too.
- No stacking or rebase dependency declared against
main; the #549 relationship is described but not enforced. - Reviewer queue to be aware of:
metrics.rsis also claimed by #549, #542 and #334 — whichever lands first sets the context for the others; #548's description reasons only about #549.
Open questions / not found
- Whether any maintainer considers #536 an adequate authorization for the work; no maintainer has commented on #536, #537, #548, #549 or #541 in the record.
- Why the queue histogram was anchored at runtime arrival instead of HTTP admission (the issue's wording); no comment explains the choice, and the description does not name it.
- Whether the intent is to migrate the four host-cache histograms onto the new generic type, or to keep two implementations; not addressed in the description or the diff.
- No Windows or non-Linux verification of
process_*(by design nothing is rendered), and no evidence of a scrape against a Windows build. - No measurement of the added per-completion/per-step overhead; no benchmark was run or claimed.
- #549's actual merge interaction with #548 was not tested, only argued from disjointness.
- Whether
flare_request_prompt_tokens's inclusion of prefix-cache-reused tokens (as documented,docs/api.md:311-312) matches how vLLM'srequest_prompt_tokenscounts; not verified against vLLM.