PR #634: Measure streaming latency after scheduler idle periods

Raw Markdown for agents: https://autobot.eidonix.com/api/v1/cases/4df059b0-f680-48ae-ad43-a369ebd1f9d6

Opened by a workflow run, Nov 30, 2026 4:53 AM EST. decide malicious: all_clear (100%): No malicious content found

explore

Author: salignatmoandal (CONTRIBUTOR; 3 merged ops/docs PRs #601/#602/#603, first work in scripts/; Discord: none provided) Motivation: The scheduler benchmark issues traffic continuously, so it cannot show how streaming behaves when the first request arrives after a server has been idle. #540 made idle-surviving timing credit possible but deferred live qualification to docs/TODO.txt:110-114, and this PR adds the opt-in driver pause needed to replay that case. Scale: +21 / −4 lines in 1 file (scripts/benchmark_scheduler.py) Proposal:

Full report · Notes

Classify intake

Selected: triage:review, enhancement

Threshold: 65%

Triage

Priority

Type

Area

Model

Apply Labels (Intake)

Applied: +triage:review, +enhancement

Value Proposition

Value Proposition: PR #634 "Measure streaming latency after scheduler idle periods"

Charter alignment — real but thin. #634's only charter hook is "address a maintainer request": #540 (merged 59adc480) left core-Flare's open item docs/TODO.txt:110-114 asking to qualify idle/resume in live Helios, and a client-side idle probe is the natural counterpart to #540's simulator work (which models idle as an in-run arrival gap in scripts/scheduling_sim/). But #634 never cites that item, does not close it, and no issue, roadmap item, bug, or docs change backs it. It adds two opt-in switches to scripts/, brushing against "Stay focused" and "Be explicit and pin everything" (requests_per_lane or 1, :226; duration or 0, :156). Placement is contestable: AGENTS.md:9-13 and commit 17bb3c4a put qualification drivers in hyperflare-recipes — though tests/server/test_scheduler.py is an in-repo precedent for scheduler SSE-gap measurement, and the TODO lives in core Flare.

Novelty & status — genuinely additive. Nothing on main since the base 0a8c20f, and no other open or merged PR in 180 days, touches scripts/benchmark_scheduler.py. tests/server/test_scheduler.py has no idle-resume case. Not superseded, not obsolete.

Value vs cost — small cost, weakly supported benefit. +21/−4, stdlib only (math already imported), continuous path behaviour-identical, zero runtime/scheduler effect. Maintenance cost is genuinely low. But the headline benefit is not what the code measures: post-pause first-token latency is only available via the pre-existing ttft_median_seconds (:169), which the description never names, while the new idle_seconds_before_burst (:227-228) is computed against a started timestamp taken before the POST (:27) — a pause self-check, not a wakeup latency. Burst rows also silently redefine issue_duration_seconds (now null, :164) and tokens_per_second (:165) under unchanged keys. Evidence is a prose-described stub SSE server; nothing ran against flare run, and the flags are undiscoverable from docs/, which never mentions the script (docs/core-design.md:1818-1838 has no idle-resume row). This area has precedent for demanding measured benefit (#353 closed for lack of it).

Verdict: Worth it with changes. Keep the tool — small, additive, correctly client-side for the docs/TODO.txt:110-114 item — but require: (1) cite that TODO and add a discoverable docs note/row; (2) report post-pause TTFT via ttft_median_seconds, rename/scope idle_seconds_before_burst as a pause-verification check, and use distinct keys for burst-mode fields; (3) remove the or 1 / or 0 implicit defaults; (4) attach one real JSONL sample against an exported core through flare run (AGENTS.md:497-499); (5) confirm a Signed-off-by trailer (CONTRIBUTING.md:19) and obtain triage labels plus CI on the head commit.

Full report Decide Value: yes (100%): This change is worth reviewing: it provides value to the project in line with its charter.

Subtraction and simplicity

Subtraction review of #634 (+21/−4, scripts/benchmark_scheduler.py). The diff is already lean — no new import, function, wrapper or dead code, and the continuous default path is untouched — so this is one high-value subtraction plus one low-value one, not a rewrite.

  1. (High) Delete --requests-per-lane (:189-190) and collapse the tri-state loop. It is unexercised (evidence ran 1 per lane), its extra repeats are flattened into one rows list (:158) so ttft_median_seconds (:169) stops isolating the post-idle first token, and it forces both magic defaults: start + (duration or 0) (:156) and args.requests_per_lane or 1 (:226) — against the charter's "No magic defaults" and AGENTS.md:188-193. Its help text says "(default: 1)" while argparse default is None, so the JSONL configuration line (:214) logs null for a burst of 1. Replace with requests_per_lane=math.inf, one condition while len(results) < requests_per_lane and time.perf_counter() < deadline[0], deadline[0] = start + duration, and trial(..., 0.0, requests_per_lane=1); drop the arg and its validation branch (:200-201). Net −1 flag, −1 branch, −1 ternary, −2 implicit defaults.
  2. (Low) idle_seconds_before_burst (:223-228) is redundant with configuration.idle_seconds on the same line (:214) and measures sleep + connect + thread jitter, since started is stamped before the POST (:27). Drop it, or keep only time.perf_counter() - pause_started around the sleep.

Lean and correct as-is: math already imported (:11), parser.error style matches benchmark_prefill.py:23 (not opened) / benchmark_roce.py:49-65 (not opened), CLI append-only, no duplication (nothing imports the script; scheduling_sim idle gaps are a different layer). Pre-existing dead --pair-index/--variant/--pair-order (:192-194) are not this PR's debt.

Open: whether any use case needs >1 request per lane rather than more --trials; whether the new field ever differed from --idle-seconds (unreported); whether a0467e2 has a Signed-off-by trailer.

Full report · Notes

Correctness and contracts

Reviewed PR #634 (scripts/benchmark_scheduler.py, +21/−4) for correctness, contracts and system-level consequences. The client-side edits are safe — no runtime change, continuous mode behavior-identical — but the burst tool does not reach the state it exists to observe, and its new headline field measures nothing about the server.

Findings, most important first:

  1. Major — the burst cannot trigger a funded refresh (the PR's stated target). A refresh needs a cost stale beyond estimate_ttl_ns = 30_000_000_000 (helios/src/scheduler/policy.rs:38, cost.rs:100-101) and a differing previously-executed stale key: self.costs.stale_keys().filter(|key| *key != ordinary.cost_key()) (policy.rs:1238-1240), where stale_keys yields only observed keys (cost.rs:271-274). The PR's evidence ("at least 100 ms") is ~300× below the TTL, and a homogeneous burst only ever executes the ordinary shape. Nothing in the CLI help (:187-190) or validation (:198-201) says so.
  2. Major — idle_seconds_before_burst is a self-check, not latency. It is min(row['started']) − pause_started (:227-228) where started is taken before the POST (:25-29), so it can never be less than the sleep. The real post-pause number is the pre-existing ttft_median_seconds (:169), unnamed in the description.
  3. Major — no server-quiescence gate, and the window is contaminated. The pause is a bare time.sleep (:223-224) entered only after trial() returns, which includes two blocking /metrics scrapes (:141, :174); the runtime parks only when nothing is outstanding (helios/src/server/runtime.rs:1236-1251), so the flag's idle gap cannot be correlated with the latency seen.
  4. Major — flare_scheduler_executions_total{reason="timing_refresh"} is scraped but never parsed (:174, helios/src/server/metrics.rs:931-938), so no JSONL row can distinguish a post-idle wakeup from ordinary service.

Minor: idle mode reuses JSONL keys with new meanings (issue_duration_seconds becomes null, tokens_per_second spans a burst, :164-165); --requests-per-lane N is N sequential rounds, so only round one is concurrent post-idle traffic (:147-151); the docs/TODO.txt:110-114 authorization is neither referenced nor closed; no automated check exercises the new branches.

Open questions: stub server and sample rows are not attached, so the field's accuracy is unverified; no Signed-off-by could be confirmed.

Full report · Notes

Final review

Recommendation: Changes Requested

This +21/−4 change to scripts/benchmark_scheduler.py is well-scoped, safe, and leaves the default continuous benchmark path behavior-identical with zero runtime or dependency impact. However, two concrete issues should be fixed before merge: (1) omitting --requests-per-lane with --idle-seconds writes "requests_per_lane": null into the JSONL configuration header while silently running 1 via an implicit or 1 default—and the unexercised --requests-per-lane > 1 path runs requests sequentially per lane while flattening all rounds into ttft_median_seconds/burst_gap_*, diluting the post-idle first-request latency it aims to measure; and (2) the new CLI validation and burst path have no automated test coverage in tests/ (which is all .github/workflows/python-cpu.yml (not opened) runs), leaving the locally described stub-server smoke check unverifiable in CI. Both are small fixes, and the cleanest resolution for (1) is simply deleting --requests-per-lane so each burst issues one request per lane.

Merge Risk

Level: Low

Walkthrough

Pre-merge Checks

Blockers

None.

Should Fix

  1. Fix recorded JSONL configuration provenance mismatch and implicit or defaults (best fixed by removing --requests-per-lane) — scripts/benchmark_scheduler.py:147-151, 156, 189-190, 214, 225-226

    • Verified behavior & impact: --requests-per-lane advertises (default: 1) in help text (:190) but leaves argparse's default as None, then relies on requests_per_lane=args.requests_per_lane or 1 (:226) alongside duration or 0 (:156). Because :214 serializes {**vars(args), ...} into the JSONL header before the trial loop, an idle run that omits --requests-per-lane records "requests_per_lane": null in its measurement artifact while actually executing 1 request per lane (and logs "seconds": 120 even though --seconds is unused in burst mode and each trial row records "issue_duration_seconds": null at :164). In addition, when --requests-per-lane > 1, each worker lane issues requests synchronously in a while loop (:147-151) and trial() flattens all rounds into ttft_median_seconds / ttft_p99_seconds / burst_gap_* (:158-171) with no round/ordinal marker—so rounds 2..N are non-idle back-to-back requests that dilute the post-idle first-request latency summary, and the > 1 path was never exercised in Evidence.
    • Fix: Prefer deleting --requests-per-lane (see ## Subtract / Simplify below) so each idle burst always issues one request per lane with zero implicit defaults. If --requests-per-lane is intentionally kept, resolve its effective integer value before logging configuration at :214, replace duration or 0 at :156 with if duration is not None: deadline[0] = start + duration, emit requests_per_lane on burst trial rows, and document in the flag help that values > 1 issue sequential follow-up requests per lane whose timings are aggregated into the trial summary.
  2. Add a CPU unit test exercising CLI validation and idle/continuous modes against a local SSE server — scripts/benchmark_scheduler.py:140-158, 198-201, 220-228

    • Verified behavior & impact: .github/workflows/python-cpu.yml:33 (not opened) runs .venv/bin/python -m pytest tests/ -q, and nothing in tests/ imports scripts/benchmark_scheduler.py. The PR's Evidence section relies on a manual, unattached local SSE stub run, so neither the new parser.error(...) guards nor the burst-mode JSONL output and idle_seconds_before_burst calculation are verified by CI or protected against regression.
    • Fix: Add a focused test module (e.g., tests/test_benchmark_scheduler.py (not opened), loading the script via importlib.util.spec_from_file_location as in tests/preparation/test_setup_preparation.py:15-18) with a small local http.server SSE handler covering: (a) rejection of non-finite / <= 0 --idle-seconds (and --requests-per-lane misuse if retained), (b) idle-mode burst execution emitting idle_seconds_before_burst >= idle_seconds, exact per-lane request count, and accurate configuration metadata, and (c) continuous-mode control output remaining deadline-bounded.

Subtract / Simplify

  1. Delete --requests-per-lane and collapse trial() to a single explicit duration is None burst branch — scripts/benchmark_scheduler.py:140-158, 189-190, 200-201, 225-226
    • Deleting --requests-per-lane removes an unexercised CLI switch (AGENTS.md:188-193), eliminates the sequential-round TTFT dilution footgun, fixes the "requests_per_lane": null configuration provenance mismatch, and removes both implicit or defaults (duration or 0 and args.requests_per_lane or 1). Operators already control the number of post-idle samples via --trials.
    • Clean, bug-free replacement in trial(url, bodies, duration):
      def trial(url, bodies, duration):
          ...
          def worker(lane, body):
              results = []
              barrier.wait()
              while (not results if duration is None else time.perf_counter() < deadline[0]):
                  row = request(url, body, stream=True)
                  row['lane'] = lane
                  results.append(row)
              return results
          with concurrent.futures.ThreadPoolExecutor(max_workers=len(bodies)) as pool:
              jobs = [pool.submit(worker, lane, body) for lane, body in enumerate(bodies)]
              start = time.perf_counter()
              if duration is not None:
                  deadline[0] = start + duration
              barrier.wait()
              rows = [row for job in jobs for row in job.result()]
      
      and call trial(args.base_url, bodies[:concurrency], None) in the idle branch (:225). Continuous mode (duration=args.seconds) remains byte-for-byte identical in behavior, while burst mode (duration=None) runs exactly one request per lane without touching deadline.

Nits

Dropped on verification

Full report

Classify triage

Selected: triage:review

Threshold: 65%

Triage

Apply labels

No label changes Decision to Test: no (100%): Testing will not add significant value as the code stands today. The code is either not yet ready to merge, or adequate testing has already been done to validate the contents of the code, or the available hardware is not suitable to test with.