Subtraction, Simplicity & Conventions review — PR #634
scripts/benchmark_scheduler.py, +21 / −4, one file, head a0467e2.
Key findings
- The diff is already lean. No new import (
mathat :11 predates the PR), no new function, no wrapper, no fallback layer, no dead code added, and the continuous-mode path (scripts/benchmark_scheduler.py:220-221) is byte-for-byte unchanged. This is not a PR that needs a rewrite; there is exactly one high-value subtraction. - One flag carries the PR's real complexity:
--requests-per-lane(scripts/benchmark_scheduler.py:189-190). It is unexercised by the PR's own evidence ("two lanes with one request per lane"), its output cannot be separated from the post-idle first request it is supposed to isolate, and it is the reason for the change's two magic defaults. Deleting it collapses the worker loop to a single condition, removes one CLI validation branch, one ternary and bothordefaults — net −1 flag, −1 branch, −1 ternary, −2 implicit defaults. - Two magic defaults violate the charter's "Be explicit and pin everything. No magic defaults":
deadline[0] = start + (duration or 0)(:156) andrequests_per_lane=args.requests_per_lane or 1(:226). Both exist only to makeduration=Noneandrequests_per_lane=Nonetolerable, i.e. they are scaffolding for the flag above. - Recorded configuration disagrees with help text. The help says "(default: 1)" (:190) but the argparse default is
None, so the JSONLconfigurationline (:214) logsrequests_per_lane: nullwhile a burst of 1 was actually run — a provenance lie in a measurement tool. idle_seconds_before_burst(:223-228) is redundant, low value. The configured pause is already on the same JSONL line viaconfiguration(:214), and the measured value is sleep + TCP connect + thread-scheduling jitter, not latency.- No duplication of a repo helper. Nothing in the repo imports this script (
search_code "benchmark_scheduler"→ zero matches outside it); the only other idle-gap implementation is in-simulation (scripts/scheduling_sim/learning_scenarios.py:88-92(not opened), arrival gaps between requests) and is not reachable from a live HTTP client driver. - The pre-existing dead flags
--pair-index/--variant/--pair-order(:192-194) are not this PR's debt. They are parsed and never read since17bb3c4a; the PR correctly does not expand them, and its "replay across builds" benefit should rest on--reuse-requests(:196).
Suggestion 1 (high) — delete --requests-per-lane, collapse the tri-state worker loop
Three sites, all in scripts/benchmark_scheduler.py.
Site A — the tri-state condition, :147-148 (inside trial()):
while (len(results) < requests_per_lane if requests_per_lane is not None
else time.perf_counter() < deadline[0]):
row = request(url, body, stream=True)
Site A′ — the magic default in the same function, :156:
deadline[0] = start + (duration or 0)
Site B — the flag and its validation, :189-190 and :200-201:
parser.add_argument('--requests-per-lane', type=int,
help='Requests per lane in each idle-mode burst (default: 1).')
...
if args.requests_per_lane is not None and (args.idle_seconds is None or args.requests_per_lane < 1):
parser.error('--requests-per-lane requires --idle-seconds and must be positive')
Site C — the call site with the second magic default, :225-226:
result = trial(args.base_url, bodies[:concurrency], None,
requests_per_lane=args.requests_per_lane or 1)
Replace with:
def trial(url, bodies, duration, *, requests_per_lane=math.inf):
...
while len(results) < requests_per_lane and time.perf_counter() < deadline[0]:
row = request(url, body, stream=True)
...
deadline[0] = start + duration
result = trial(args.base_url, bodies[:concurrency], 0.0, requests_per_lane=1)
and delete the --requests-per-lane argument (:189-190) plus its validation branch (:200-201). Keep the --idle-seconds validation (:198-199) as is.
Why this is a subtraction and not a taste call:
- Unexercised. The Evidence section reports "Two lanes with one request per lane yielded two completed requests per burst" — the >1 path was never run, and no sample JSONL is attached.
- The extra repeats destroy the metric the PR exists to produce.
rows = [row for job in jobs for row in job.result()](:158) flattens all repeats in a lane into one list, andttft_median_seconds/burst_gap_median_seconds(:169-171) aggregate over it with no ordinal marker. With--requests-per-lane 4, the post-idle first token becomes 1 of 4 samples per lane, so the summary number the operator compares across builds is no longer a post-idle first-token latency. The raw rows retainstartedandlaneand could be reconstructed downstream, but nothing tells the reader which row is ordinal 0. - It is the sole reason for both magic defaults (:156, :226), which the charter explicitly forbids ("Be explicit and pin everything. No magic defaults") and AGENTS.md:188-193 reinforces ("Do not add … configuration switches without a concrete requirement").
- It produces a false provenance field (help "(default: 1)" vs recorded
null).
After the change, the single while condition covers both modes truthfully: duration bounds continuous trials (math.inf count), the count bounds burst trials (0.0 duration, already expired at start + 0.0). issue_duration_seconds (:164) becomes 0.0 rather than null — truer, since no deadline bounded the burst trial.
If something between 1 and N per lane is genuinely wanted, the honest shape is one flag with a real argparse default=1, so the recorded configuration matches what ran — but the PR's stated goal (first-token latency and SSE gaps after a pause) is satisfied by 1, and the flag should be added when a run demonstrates it is needed.
Suggestion 2 (low) — drop idle_seconds_before_burst
:223-228:
pause_started = time.perf_counter()
time.sleep(args.idle_seconds)
result = trial(args.base_url, bodies[:concurrency], None,
requests_per_lane=args.requests_per_lane or 1)
result['idle_seconds_before_burst'] = min(
row['started'] for row in result['rows']) - pause_started
Why it can go: the configured pause is already recorded on the same JSONL line via {'configuration': {**vars(args), ...}} (:214), so the new key adds no information the file does not already carry. And the value it adds is not latency: row['started'] is stamped inside request() before the POST is issued (scripts/benchmark_scheduler.py:27, returned at :65), so the number is sleep + connection(url) + thread wake-up jitter — for a local server it reads ≈ --idle-seconds and is a self-check that the pause happened, not that the server was slow to wake. The genuine post-pause latency is the pre-existing ttft_median_seconds (:169).
If the field is kept (it does give a per-trial jitter record), narrow it to the quantity it can honestly claim, deleting the min(...) generator over result['rows']:
pause_started = time.perf_counter()
time.sleep(args.idle_seconds)
result = trial(args.base_url, bodies[:concurrency], 0.0, requests_per_lane=1)
result['idle_seconds_before_burst'] = time.perf_counter() - pause_started
Also delete pause_started = time.perf_counter() before the sleep if the field is dropped entirely — the interaction then needs only the time.sleep(args.idle_seconds) line plus the branch.
Already lean — checked and no action
- No new import or dependency.
mathat :11 is used bypercentile(:125) and reused formath.isfinite(:198);timeat :14. Stdlib only, Python 3.12 perpython-cpu.yml(not opened). - No new function, class, wrapper or fallback layer. The only signature change is a keyword-only parameter on
trial()(:140). No touched call sites outside :218 (warmup, unchanged) and the two branches at :221/:225. - Validation style matches the repo exactly.
parser.error(...)is the house pattern —scripts/benchmark_prefill.py:23(not opened),scripts/benchmark_roce.py:49-65(not opened),scripts/check_response_completion.py:28(not opened),scripts/qualify_worker_failure.py:168(not opened),scripts/set_release_version.py:107(not opened) — and rejecting non-finite / non-positive values mirrorsscripts/qualify_qsa_fixed_partitions.py(not opened). Failing loudly on misuse is correct and cheap; it is not the thing to subtract. - CLI is append-only, defaults unchanged.
--idle-secondsdefaults toNone(:187-188) and the continuous branch (:220-221) is untouched, so every existing invocation produces identical output. - No helper duplication. Nothing imports this script, and the only other idle-gap notion lives a layer away in
scripts/scheduling_sim/learning_scenarios.py:88-92(not opened) /scripts/scheduling_sim/learning_run.py:243-244(not opened) (arrival gaps inside one simulated run, not a driver-level pause). Extracting a shared helper would be worse, not better. - Style is consistent with the file's existing dense one-line-dict formatting; no reformatting or renaming churn, which AGENTS.md:188-193 asks contributors to avoid.
Convention notes folded into the suggestions above
- Charter, "Be explicit and pin everything. No magic defaults" → :156 and :226 (Suggestion 1).
- AGENTS.md:188-193, "Do not add … configuration switches without a concrete requirement" → the unexercised
--requests-per-lane(Suggestion 1). - Charter, "Stay focused … random switches" → same flag; the
--idle-secondsflag itself is focused and justified by the #540 follow-up.
Open questions / could not be found
- Whether the >1
--requests-per-lanepath produces anything an operator wants: no sample JSONL, no comparison table, and no stated use case distinguish "N requests per lane" from "N trials", which the existing--trialsalready provides. - Whether
idle_seconds_before_burstever read a value materially different from--idle-secondsin the stub run — not reported, so the field's only claimed value (observed vs commanded pause) is unverified. - Whether any live deployment currently uses
scripts/benchmark_scheduler.pyat all (nothing in.github/workflows,docs/ortests/references it), so the practical cost of keeping the extra flag is low — but so is the cost of removing it. - Whether commit
a0467e2carries theSigned-off-bytrailer required byCONTRIBUTING.md:19(not opened); readable only on GitHub, not through the review tools.