Architecture report · NVIDIA/hyperflare-inference #548

Raw Markdown for agents: https://autobot.eidonix.com/p/0d57f471-9b4e-4581-95c3-e8ee63d2d3ae.md

Architecture & scope review — PR #548 "Add request latency histograms and process metrics"

Head reviewed: a34c4d06 ("Hoist completion values and tighten stat parsing"), atop d64c3ea3 ("Exclude cancelled responses and reuse host helpers") and ebecef13. No commits since my previous pass. All 10 changed files read with surrounding code. Judged against the charter (read in full), AGENTS.md, docs/design-review.md, and the surrounding Helios/selene/eos code.

Key findings

Verdict: should-fix issues only — no blocking architectural defect. The approach is correct and belongs in this layer. Recording all observations inside Metrics::request_completed, the one function that already increments flare_requests_completed_total, is exactly the charter's "solve the right problem in the right place": divergence between counter and histograms becomes structurally impossible, and fixed-bound histograms need no per-request storage. The stamps live on Incoming, the request's own lifecycle record, and survive preemption because parking moves the whole struct. Snapshot/format=json is untouched, there is no Cargo change (libc already unconditional), Windows compiles to a no-op, and there is no flag, no per-model branch, no environment switch, and no preparation/runtime boundary crossing.

I explicitly considered and rejected the obvious alternative — sourcing these timings from the scheduler trace (metrics/scheduler.rs). That trace is a gated, bounded diagnostic (detail_requested: AtomicBool at :94, TRACE_CAPACITY = 1024 at :21, is_enabled() at :117), so building histograms on it would need exactly the switch AGENTS.md:188-190 forbids. RequestTimes is the right design, not a duplicate one.

Four should-fix items remain. None is a code defect: one is procedural (scope authorization), one is a narrow layering ask in eos, one is a duplication question, one is an evidence-honesty question in the description. Three nits follow. The PR is still a draft with no human reviews and no CI checks on the head commit, so everything below is a pre-merge ask, not a post-merge objection — the description items can be fixed by rewording alone.


Should fix

1. Residual OS access in a serving formatting module, and a mutating helper used as a getter

helios/src/server/metrics/process.rs:57-70. Rule: AGENTS.md:20-22 — "The eos/ crate holds the host operating-system operations that Helios and Selene use"; helios/src/os.rs:8 is just pub(crate) use flare_eos::*;.

d64c3ea3 fixed most of this (crate::os::page_size() at :61 → eos/src/unix.rs:73-75; crate::runtime_core::open_descriptors() at :68; the hand-rolled getrlimit gone). Remaining:

Fix: add clock_ticks() -> Option<u64> and open_file_limit() -> Option<u64> (getrlimit only) to eos/src/unix.rs beside page_size, and drop the raise_open_file_limit(0) call. No new code outside eos.

2. Scope authorization: "monitoring parity with vLLM" is not a merge criterion

PR description ("Closes #536"); issue #536; AGENTS.md:165-169, :201-203; charter "What gets merged" and "Alternatives / Competitors".

The stated justification is issue #536 (Napuh, outside contributor), whose summary is "This makes it hard to move existing vLLM Grafana dashboards and SLO alerts to Flare", with a column headed "vLLM metric (reference)".

Nothing here is architecturally wrong, and the observability gap is real: tail latency, queue delay, prefill time and per-request decode rate genuinely are unobservable from a scrape today, and #536's "Why histograms" section is a sound argument. But the fix is procedural, and cheap while the PR is a draft: get a maintainer decision recorded on #536, or reframe the description around the defect (p99/tail latency is unobservable from /metrics) rather than competitor parity. Worth flagging for that decision: the same author's #549, #551 and #552 rebuild overlapping observability surfaces (KV pages held by active requests; per-request timings on final responses), and #553 was halted as off-charter — a maintainer should shape this cluster once rather than merge four variants.

3. A third histogram convention added where three already coexist, and a copied metric formatter

helios/src/server/metrics.rs:214-298 vs :200-210, :670-692, :705-711, :851-876, :1029-1065; helios/src/server/metrics/process.rs:48-54 vs metrics.rs:1597-1602. Rule: AGENTS.md:188-193 — "Do not add frameworks, extension points, speculative compatibility, fallback layers, or configuration switches without a concrete requirement. … Refactoring must directly support the requested behavior or remove a demonstrated source of defects or cost."; docs/design-review.md:16-25 (principle 1, keep Helios simple).

metrics.rs now contains four ways to declare and render a histogram:

Mechanism Where Shape
HOST_TIME_BUCKETS/HOST_TOKEN_BUCKETS :200-210, observe :689, render :1029-1065 [u64; 8], u64::MAX as +Inf
flare_host_cache_retirement_seconds :705-711, :851-876 counts pushed from selene, rendered by hand
new Buckets<N>/Histogram<N> :214-298 [f64; N], f64::INFINITY
single-value families via metrics::metric :1597-1602 fixed flare_ prefix

The PR adds the third bucket convention in one module with no guidance for the next author; the diff there is +219/−0 and leaves the older ones in place (the PR does not touch :200-210 / :670-692 / :1029-1065).

Fix, in order of preference:

  1. Adopt Histogram as the single observe-based convention and migrate the three host_* lookup histograms onto it (:670-692 and :1029-1065). That deletes the .position(...).unwrap() at :689 and host_cost_sums, and is justified under AGENTS.md:193 as removing a demonstrated defect source. The new type is genuinely better: it carries bounds and scale together, which is why latency.rs:63-109 could reuse it for FirstResponseSamples.
  2. Do not try to migrate flare_host_cache_retirement_seconds (:851-876): those counts are pushed from the selene store, not observed, so it legitimately cannot use Histogram. Say so in a comment if the migration happens.
  3. Fold process::metric (:48-54) into metrics::metric by giving the formatter a full-name parameter, with flare_ supplied by the caller. process.rs is a new file, so that copy is new duplication, not pre-existing.

Not blocking — but it is the "same thing four times" that the design-review principles push back on, and this PR is the moment to settle it.

4. "Nothing about serving changes" is asserted, not measured

PR description ("Observability only … nothing about serving changes"); docs/design-review.md:97-105 (principle 12: report evidence honestly, disclose unrun checks and material limitations); AGENTS.md:194-199.

The added hot-path work is real, if small, and the description says there is none:

Fix: one sentence — "the added cost is one clock read per scheduled step, two stores per generated token, and one /proc read per scrape; not measured" — instead of "nothing about serving changes".

Related, description-only: the live-scrape evidence does not reconcile. Runtime families gained 5 observations while flare_time_to_first_response_seconds gained 6; the prompt-token accounting ("le=\"64\" gained exactly one … le=\"2048\" gained four") totals 5; and the text concedes the deltas "include" this agent session's requests and "exceed the three requests below", so per-request counts cannot be checked, and no duration is attributed to a single request, so decode_sum/e2e_sum cannot be cross-checked against the reported completion tokens (60, 1500, 695). The base is the AzallazA fork commit 5ffe4d54 with this diff cherry-picked, not main — that limitation is disclosed, which is correct. Note also that the description's "CI covers the first two" is an expectation, not an observation: the head commit has no CI checks. Fix: keep the scrape as a labelled smoke check and lean on request_histograms_bucket_completed_request_timings (metrics.rs:1651-1697), which does establish the bucket boundaries and the zero-token exclusions.


Nits


Verified sound (no finding)


Coverage

All 10 changed files read with surrounding code: helios/src/server/metrics/process.rs (whole file, plus eos/src/unix.rs:60-175, helios/src/os.rs:1-8, runtime_core/protection.rs:280-320,354), metrics.rs (:1-40, :200-400, :440-480, :1380-1424, :1630-1697), runtime.rs (:151-245, :293-302, :1310-1420, :1755-2015, :2187-2230, stamp construction at :913, :3254), http.rs (:120-200, :380-470, :540-656), latency.rs (:1-140), server.rs (:9-35, :640-718), docs/api.md (:280-340), runtime_core/{mod.rs,protection.rs}, runtime/phase_tests.rs (:4540-4650), and the rules (AGENTS.md:1-230, docs/design-review.md:1-231, charter, .github/workflows/native-serving.yml:56-68 (not opened) for what CI actually runs). Not re-read this run: the remainder of docs/api.md, and the diffs of #537/#549; Windows behaviour of process.rs is inferable only from its #[cfg(target_os = "linux")] gates (:10-13, :18, :39, :47, :56, :128) and eos/src/windows.rs:152-215 (not opened).

Open questions (only a maintainer or a measurement can settle)

Link: https://github.com/NVIDIA/hyperflare-inference/pull/548