fix(perf): improve metric accuracy, validation, and shutdown - #1654
Merged
Conversation
Use nearest-rank percentiles, validate incompatible perf arguments, and avoid unnecessary visualizer snapshots. Record the full lifecycle of failed requests so wall-time and throughput remain accurate. Cancel pending work on signals, finish cleanup, and convert signal cancellations to conventional CLI exit codes without hiding internal cancellation.
git-jxj
marked this pull request as ready for review
August 27, 2026 10:39
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes several correctness, validation, and lifecycle issues in the perf benchmark path:
CancelledErrortracebacks after cleanup.The changes are covered by deterministic unit, local-server, process-level CLI, and regression tests.
Root Cause
The percentile helper used
int(n * p / 100)as a zero-based index instead of nearest-rank's one-basedceil(n * p / 100) - 1. The initial correction also removed the legacyNone-to-NaN fallback, which could break reports produced from incomplete metric data.Failure records either kept the dataclass defaults (
start_time=completed_time=0) or captured both timestamps only after an exception had already occurred. Some API plugins catch their own failures and return an incompleteBenchmarkData, so fixing only the outer exception path was insufficient.The perf argument model did not reject combinations that the dispatch strategies cannot execute safely. Signal handling called
loop.stop()directly; switching only to task cancellation allowed cleanup to run but still propagatedCancelledErrorthrough the CLI.Changes
Reproduction
On the unmodified base:
After this change, the percentile result is
{50: 49, 99: 98}, failed request lifecycles contribute to the real wall-time window, missing percentile values remain NaN, invalid arguments fail immediately, and Ctrl-C exits quietly with code 130 after cleanup.Validation
Targeted regression tests:
Result:
Adjacent perf regression suite (unit and local mock-server tests only):
CI smoke test:
Result:
test_multi_parallel_sweepremains skipped by its existing environment gate. All current Ruff and repository pre-commit checks passed.Scope
The changes are limited to perf metrics, validation, request lifecycle handling, signal-to-CLI propagation, and their tests. They do not change request payloads, model generation behavior, benchmark datasets, or non-perf evaluation semantics. The branch is rebased onto the current
mainand contains one commit.