← Back to Pull requests

loadgen: measure sweep saturation with a closed-loop capacity probe #1038

Open
unknown opened this pull request with 533 lines diff across 6 files
View on GitHub
unknown unknown commented on Nov 07, 2026 20:19 UTC
Author

Part of #904. This is the measurement half; binding probe-derived rates to
expression stages depends on #823/#829 landing first.

Old behavior

sweep estimated saturation from a fixed 1000-request burst: the preprocess
loop sampled active-request counts every 0.5 s, derived a rate from each
sample, and took saturation_percentile (default 95) of them as the upper
bound for the generated stages. The drain tail of a burst is the least stable
part of the run, so the percentile over-represents the burst peak and the
estimate does not converge as load is added — the same server measured twice
produced different sweep bounds.

New behavior

Opt-in load.sweep.probe replaces the burst with a closed-loop concurrency
ladder. Each rung holds in-flight concurrency at N, skips settle_duration,
then measures throughput X(N) and mean latency R(N) over rung_duration.
Little's law (N = X * R) is validated per rung; a rung that was not held at
N is marked non-stationary rather than silently biasing the estimate. The
ladder grows N by growth_factor until the upper confidence bound of the
marginal throughput gain drops below gain_threshold, bounded by
max_concurrency (and by workers x per-worker concurrency).

The rung curve is fit two ways — an isotonic plateau that never extrapolates
and a saturating-curve asymptote — and the asymptote is kept only when it is
close to the measured plateau. r_sat and n_knee are reported with
bootstrap confidence intervals, and generated stages are spaced up to r_sat.

The probe is invisible to the benchmark it configures: probe traffic runs
under negative stage ids and is dropped from reports, and worker concurrency is
restored before the measured stages start.

Changes

  • inference_perf/loadgen/probe/ — new package: result.py (rung/probe

  • records), metrics.py (per-rung X, R, error rate, Little's law),
    stationarity.py (settle/measure split, drift detection), ladder.py
    (growth + stop policy), estimator.py (plateau + asymptote fits, bootstrap
    CIs, r_sat/n_knee), plus README.md.
  • config/loadgen/config.py — ProbeConfig with 7 documented fields;

  • SweepConfig.probe; validation that max_concurrency >= start_concurrency
    and that sweep.probe requires num_workers > 0.
  • loadgen/load_generator.py — generate_stage_rates(),

  • _probe_preprocess(), _run_probe_rung(), _collect_rung_metrics(),
    _restore_worker_concurrency(); shared_max_concurrency now always created
    on the mp_run path.
  • metrics/request_collector/ — abstract snapshot(); local and

  • multiprocess implementations (multiprocess accumulates into self.metrics).
  • main.py — passes the collector into LoadGenerator.

  • Tests — 6 probe unit-test files, test_probe_preprocess.py (real worker

  • processes, rungs N=1/2/4), test_request_collector_snapshot.py, 3
    ProbeConfig validation tests.
  • Docs — docs/loadgen.md ("Closed-loop capacity probe" section),

  • docs/config.md (fields + note), docs/cli_flags.md (regenerated).

    Testing

  • pytest tests/required/loadgen/probe tests/required/metrics/test_request_collector_snapshot.py

  • → 65 passed.
  • pytest tests/required/loadgen/probe/test_probe_preprocess.py → 1 passed

  • (rungs N=1,2,4; r_sat 65.00; stages ran to COMPLETED).
  • Probe package coverage 98% (301 stmts, 6 missed).

  • ruff format --check + ruff check clean at the pdm.lock-pinned 0.15.20.

  • mypy --strict clean on all changed modules.

  • python scripts/sync_cli_flags_doc.py --check and

  • sync_runtime_metrics_doc.py --check pass.
  • Full pytest tests: 3007 passed, 38 skipped. Of the 28 failures, 26

  • reproduce on an unmodified checkout of the same commit on this Windows
    machine (fork, SIGKILL, killpg, path separators, cp1252); the two
    remaining are load-dependent flakes that pass in isolation
    (test_worker_matrix 5/5 twice; test_registry run-elapsed fails 4/5 on the
    baseline too). check:cov needs PDM and a main fetch, so it runs in CI.

    Not in this PR

    Binding the probe-derived rates to expression stages, which #904 also
    describes. That depends on #823 and #829; probe_result and the r_sat/
    n_knee outputs are the contract that follow-up will read.

    Diff: 533 lines (+399 / -134) across 6 files Reviewer: rishabhsinha17 Review duration: 32948m
    All Vouch review confidence checks passed
    Residual risk 0.28 = Change Risk (0.53) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.53 · 533 lines diff across 6 files
    0.53
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.376
    Shallow Review Depth shallow_review_depth
    0.344
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    1 comments
    "Review active on #1038"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52.9% (MEDIUM) · Higher = larger blast radius
    52.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 28.2% · Safe to merge
    28.2%