Recommendation: Ready To Merge
PR #548 cleanly implements per-request latency/size/preemption histograms and related runtime/admission counters on top of current main (c146d7be, post-#620), with all blocking and substantive code items from lukealonso's 2026-11-28 review resolved at 93fdc89. The worker-owned RequestRecord keeps the hot loop allocation-free and atomic-free (fixed 84-byte InterTokenIntervals), recording at Metrics::request_completed keeps counters and distributions structurally aligned, and all new lifecycle tests exercise real Worker/ModelRuntime/HTTP paths. Before clicking merge, confirm GitHub Actions CI is green on 93fdc89, unlink the stale [closes] reference on #536 in the GitHub sidebar (the PR body already says Part of #536), and consider fixing the one-sentence doc contradiction at docs/api.md:322-325 noted under Nits.
Merge Risk
Level: Low
- Bounded, lock-free hot-path footprint:
RequestRecord(helios/src/server/metrics.rs:374-384) is owned exclusively by the single worker thread, uses fixed-size non-atomic[u32; 19]+u64inter-token storage (no heap allocations, no per-step atomics), and adds only onemonotonic_ns()call per scheduled step (helios/src/server/runtime.rs:2293), one plain update per committing step per request (runtime.rs:1861-1863), relaxed atomic histogram updates at completion (metrics.rs:607-654), and one update per sampling step (runtime.rs:1786-1788). - Backward-compatible observability surface: JSON
/metrics?format=json(Snapshot) is unchanged; the three existing host-cache histograms keep their exact names, bucket bounds, and values while migrating ontoHistogram<8>(metrics.rs:523-525, 1237-1256, pinned bymetrics.rs:2271-2292). No wire, protobuf, scheduler policy, or captured-graph contracts change. - No
mainconflict, minor concurrent-PR overlap: Verified via commit history that93fdc89is already rebased directly ontoc146d7be(maintip, post-#620). Open PR#621edits nearby admission code inhelios/src/scheduler.rs,helios/src/server/runtime.rs, andhelios/src/server/runtime/phase_tests.rs, so whichever lands second will need a routine rebase.
Walkthrough
- Unified histogram primitive & per-request completion recording (
helios/src/server/metrics.rs): IntroducesBuckets<N>,Histogram<N>,RequestRecord,InterTokenIntervals,CompletedRequest, andAdmissionLimit; migrates the three host prefix-store cost histograms ontoHistogram<8>; addsMetrics::request_completed,response_completed,first_response,model_step, andadmission_rejected; and renders 17 new histogram families plusflare_requests_output_limited_total,flare_cache_lookup_tokens_total,flare_parked_requests, andflare_admission_rejections_total{reason}in Prometheus text exposition. - Worker lifecycle instrumentation (
helios/src/server/runtime.rs,helios/src/scheduler.rs): Trackscache_lookup_tokensinRequestScheduler::admit_planned_with_checkpoint_accounting(scheduler.rs:1560, 1767); recordsmax_tokensat first admission (runtime.rs:1634-1635),first_scheduled_nsafter input packing (runtime.rs:2293-2306, reset inWorker::requeueatruntime.rs:2686), per-steptokens_committed(runtime.rs:1861-1863),preemptions(runtime.rs:2170),model_steptokens (runtime.rs:1786-1788),parkeddepth viapublish_gauges(runtime.rs:1232-1240), andGenerationCapacity/RequestQueuerejections (runtime.rs:897-898, 973-974). - HTTP response & first-response histograms (
helios/src/server.rs,helios/src/server/http.rs,helios/src/server/latency.rs,helios/src/server/protocol/encode.rs): RecordsHttpSlotsrejections inadmit_http(server.rs:815) and batched remainder-slot acquisition (http.rs:237-240); tracks per-choiceTermination::CancelledinEncoder::finish/choice_generated_tokens(encode.rs:600, 688-693) to feedresponse_completed(http.rs:605-609); and feedsflare_time_to_first_response_secondsfromFirstResponse::output(latency.rs:120-121). - Documentation & tests (
docs/api.md,helios/src/scheduler/tests.rs,helios/src/server/metrics.rs,helios/src/server/runtime/phase_tests.rs): Documents the new Prometheus series and their populations indocs/api.md:305-385and adds isolated unit and worker/HTTP tests covering requeue queue-time reset, forced reasoning-close decode suppression, preemption preservation, admission rejections, inter-token absorption, and multi-choice tool-limit cancellation.
Pre-merge Checks
- [PASS] Security / malicious screen: Pure metrics/observability and test/doc additions; no unsafe code, external I/O, dependency changes, or instruction-injection patterns.
- [PASS] Charter & value fit: Model-agnostic observability that surfaces tail latency, queue/prefill/decode splits, and preemption distributions without adding per-model branches, flags, or steady-state allocations;
process_*remains cleanly out of scope (Part of #536). - [WARN] Related / duplicate / conflict check: Already cleanly rebased onto
c146d7be(maintip) with no competing PR; however, GitHub still lists[closes]on#536(unlink in UI so#536stays open forprocess_*), and open PR#621edits the same scheduler/runtime/test files. - [WARN] Tests & verification evidence: Author reports passing
cargo test --locked --release --manifest-path helios/Cargo.toml --features runtime-core,server(1731 passed, 46 ignored, 17 env-only failures matchingmain) andpython3 verification/helios-lifecycle/check.py(not opened) (4:30), and all new tests are isolated real-path checks; confirm GitHub Actions CI is green on93fdc89before merge since CI status is not observable here.
Blockers
None.
Should Fix
None.
Subtract / Simplify
- Deduplicate bucket-index lookup (
helios/src/server/metrics.rs:293-297,:360-364):Histogram::observeandInterTokenIntervals::observerepeat the identical 4-line.bounds.iter().position(|bound| value <= *bound).unwrap_or(...)search. Addingfn index(&self, value: u64) -> usizeonBuckets<N>lets both callbuckets.index(value)/TOKEN_SECONDS.index(value). - Fold
model_step_tokensinto theTOKEN_COUNTSrender array (helios/src/server/metrics.rs:1638-1666,:1679-1684):self.model_step_tokensuses&TOKEN_COUNTSjust like the five-element loop immediately above it and can be the sixth tuple in that array. - Optional minor churn cleanup (
helios/src/server/latency.rs:34-36,helios/src/server/metrics.rs:341-346): KeepingFirstResponseSamples(Mutex<Samples>)as a tuple struct avoids the cosmetic.0→.windowrename across six hunks (latency.rs:79, 118, 192, 198, 207, 216); similarly,RequestTimesis only ever destructured insideRequestRecord(metrics.rs:606) and can be flattened intoRequestRecordif desired.
Nits
docs/api.md:322-325contradictshelios/src/server/protocol/encode.rs:600-601andhelios/src/server/metrics.rs:2159-2165:docs/api.md:322-325says"A choice stopped at the parallel_tool_calls: false tool limit is not delivered, including a choice whose generation completed naturally before the limit stopped delivery: the encoder counts it as cancelled, and it enters neither choice histogram."In fact,encode.rs:600captureslet cancelled = cause == Termination::Cancelled;before line 601'stool_limit_reachedoverride, andmetrics.rs:2162-2165explicitly asserts[None, Some(5)]when choice 1 finishes withTermination::Eosaftertool_limit_reachedis set. Updatedocs/api.md:322-325to state that choices whose runtime generation ended asTermination::Cancelled(such as after theparallel_tool_calls: falsetool limit cancels decoding) are excluded from the choice histograms, while choices whose generation completed naturally before cancellation arrived still enter them (matchingflare_requests_completed_total).- Minor doc precision (
docs/api.md:334-336,:371-373): Optionally note thatfirst_scheduled_nsis stamped right after input packing succeeds (runtime.rs:2290-2306), and thathttp_slotsalso counts batched (n > 1or multi-prompt) HTTP 429 rejections when fewer thansize - 1additional slots remain (http.rs:230-245). - Minor defensive tweaks (
helios/src/server/metrics.rs:645-654,helios/src/server/latency.rs:118-121): Inrequest_completed, adding&& generated_tokens > 1alongsidetimes.last_token_ns > firstguardsgenerated_tokens - 1against any synthetic caller passinggenerated_tokens <= 1(impossible in production since two committing steps yield>= 2tokens). InFirstResponse::output, droppingsamplesbeforeself.metrics.first_response(...)avoids doing the bucket scan under the mutex. - Unlink stale
[closes]relation on#536: The PR body was already updated toPart of #536, but GitHub's Development sidebar still links#536as[closes]; unlink it so merging does not prematurely close#536whileprocess_*remains unimplemented.
Dropped on verification
- Correctness F1 (
flare_request_max_tokens"uncapped limit" contradicting# HELP): False.helios/src/server/request.rs:562-600(output_limit) already caps omitted limits at(configured as usize).min(remaining)and rejects explicit limits whereprompt + max_new_tokens > contextwithAdmissionError::Context(also enforced inscheduler.rs:1464-1468).request.rs:381-397splitsmax_new_tokensintobudget+reasoning_cut.after, soruntime.rs:1634-1635recovers the exact effective limit matching# HELP.scheduler.rs:1412-1417(execution_limit) only clamps speculative verification scratch, not the output limit. - Discovery / Value Prop / Correctness ("PR cannot be shown to merge cleanly after
#620"): False.search_history(ref="pr/548")showsc1314221(branch base) sits directly onc146d7be(#620, currentmaintip). The branch is already rebased cleanly ontomain. - Subtraction F1 ("Delete
InterTokenIntervals&Histogram::absorb; replace withVec<u64>"): Harmful and contradicts maintainer direction.lukealonso's review (#6) explicitly requested fixed 84-byte non-atomic[u32; 19]+u64storage; replacing it with an unbounded heap-allocatedVec<u64>would allocate O(generated_tokens) memory per request (violatingdocs/design-review.mdPrinciple 8) and execute O(generated_tokens) bucket searches and atomic RMWs at completion on the single-threaded worker loop. - Value Prop ("Split
Histogram/Bucketshost-histogram unification into a separate PR"): Contradicts maintainer direction.lukealonso's review explicitly suggested unifying the three host histograms ontoHistogram<8>here, andmetrics.rs:2271-2292pins backward compatibility. - Correctness F2 ("
flare_model_step_tokensobserves partially-failed steps againstdocs/api.md:383-385"): False.docs/api.md:383-385says"a step in which no lane made progress, such as one whose every lane failed, is not observed"— matchingif tokens != 0(metrics.rs:749). Summing prompt-computed and generated-committed tokens matches vLLM'siteration_tokens_totalforMixedsteps. - Correctness F3 ("
flare_request_e2e_secondsmeasures client drain time for streams vs body-ready for non-streams"): Already documented accurately atdocs/api.md:314-317per an earlier review round; demanding astreamlabel or scope change now is moving the goalposts. - Correctness F4 ("
http_slotsover-counts batchedsize > 1rejections"): False. Middleware only increments onIngressRejection::Full, so a batchedtry_acquire_many_ownedfailure athttp.rs:235-245incrementshttp_slotsexactly once for the HTTP 429 rejection (demoted to a doc wording nit). - Value Prop ("Change
Closes #536toPart of #536in description"): Stale — the PR description already saysPart of #536(only the GitHub sidebar link needs unlinking, noted in Nits). - Subtraction F4b ("Drop per-series population sentences from
docs/api.md:343-348, 353-357"): Low-signal/subjective — those sentences explain non-obvious cross-feature interactions (0-token completions, forced reasoning close, preemption recomputation, reasoning-budget deferral) useful in API docs before scraping. - Discovery / Value Prop ("Add test pinning
first_scheduled_nspack-order boundary; measure overhead in isolation"): Low-signal —lukealonso's review already accepted the disclosed unmeasured overhead, and the pack-order placement atruntime.rs:2290-2292is clear and well-commented.