Skip to content

Prefer complete runs for BEST and WORST results - #794

Merged
fcostaoliveira merged 2 commits into
masterfrom
codex/fix711-complete-run-ranking-20261023
Oct 23, 2026
Merged

fcostaoliveira merged 2 commits into
masterfrom
codex/fix711-complete-run-ranking-20261023

Conversation

@fcostaoliveira

@fcostaoliveira fcostaoliveira commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

A partial run can displace completed runs in BEST/WORST after a --run-count series is interrupted. A run with a failed worker also reports Interrupted: false despite the existing invalid-results diagnostic and failure exit code, allowing it to compete as a complete result.

Root cause

The ranking loop considers all runs without checking their interruption flag. Separately, joined worker failures set only the process failure status; their invalidity is not retained in the returned run statistics.

Fix

Mark a run interrupted when the existing post-join worker-failure count is nonzero. Prefer non-interrupted runs for both BEST and WORST whenever any exist; if all runs are partial, rank the available results as before. The README explains this policy.

Worker failure detection and exit codes are unchanged, including failures already classified after a timed deadline. Ordinary command errors and legitimate zero-throughput timed completion remain eligible. No completion inference uses elapsed duration, operation count, or error count.

Selection retains the original run object and its timestamps, counters, and histograms. Per-run output, numbered HDR files, aggregate population, and JSON keys remain unchanged. Failed-worker runs now correctly carry Interrupted: true in single-run ALL STATS as well as per-run/selected output and propagate it to the aggregate; this is the intended metadata correction.

Tests

Paired bounded private-loopback fixtures against base 4bade818c3642e1771a34e2faddb3fcc9b96c956, initial head 8bc426afee0e72a8cd35de819391084a86228236, and this change:

  • Partial fastest: base selects a 301 ms interrupted run at 35,853.43 ops/sec over a complete 1,014 ms run at 49.33 ops/sec. Fixed selects the complete run for both labels. Partial slowest similarly stops displacing the complete WORST candidate. Four of the six original regressions fail against the unchanged base; all pass with the filter.
  • Worker failure: a first run receives three of twenty requested replies before a socket drop; the next completes all twenty. Base and initial head exit 1 but label the first and aggregate uninterrupted and select that first run BEST. Fixed still exits 1, marks the failed run and aggregate interrupted, and selects the completed second run.
  • Ordinary -ERR control: all twenty responses complete; both old and fixed versions exit 0, keep the run uninterrupted, and allow it to rank. These deliberately different scripted response delays discriminate selection, not performance.
  • Ten new selection/process tests cover partial fastest/slowest, complete zero throughput, only-partial fallback, request-count mode, ordinary ordering, failed-then-complete, all-failed fallback, error-only completion, and failure after a timed deadline. The three worker-failure regressions fail before the metadata fix; the error-only control passes on both.
  • The ordinary ranking fixture uses distinct slow/fast/slower response delays, asserts strict displayed-rate separation, and checks explicit run identity rather than deriving an oracle from rounded ties.
  • Ten selection tests plus nine existing exit-code tests pass (19/19). Selected full JSON objects and text tables match the original run; numbered external HDR and embedded histograms retain identity. Aggregate counts retain the rounded mean over all actual runs.
  • Three existing injected-worker-exception/fatal-cleanup controls pass, with the recoverable exception tests now requiring Interrupted: true.
  • All 16 C++ unit tests and formatting checks pass. POSIX signal fixtures skip native Windows; scripted plaintext peers skip TLS/cluster cells. No local native Windows or TLS result is claimed.

Affected versions

Both defects affect unreleased master:

No release tag contains either introducing commit. Historical attribution is from source inspection; paired runtime claims are limited to the exact SHAs above.

Fixes #711.
Fixes #796.

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

🤖 Automated first-pass review — a human maintainer's review is still required before merge.

Thanks, this went through cleanly. The ranking change is small and does what it says. Rank complete runs when there are any, and fall back to all runs otherwise. Zero-throughput complete runs stay eligible. BEST/WORST still point at the original run_stats, so the histograms and timestamps stay with the run they came from. You also say 4 of the 6 new tests fail on the unchanged base, which is the bar tests/test_json_output_integrity.py already set in #364. The flipped WORST RUN RESULTS assertion in test_run_count_exit_code.py is the intended behavior change, and the README covers it.

One question, about the second commit ("Mark worker-failed runs partial before ranking results"). The PR description only covers ranking, but stats.set_interrupted(true) on worker failure also changes the JSON in a user-visible way outside --run-count. A single run whose worker fails will now report "Interrupted": "true" under ALL STATS. Until now that flag meant Ctrl+C/SIGTERM or --connection-stage-timeout. Anyone filtering on Interrupted will now catch worker failures too. I think that's arguably the more honest signal, and the top-level error already says "Benchmark worker stopped before completion". Still, it's a change to the meaning of an existing output field, so I'd mention it in the description/release notes rather than leave it implied by the ranking fix. Did you consider ranking off failed_threads separately and keeping Interrupted for user/abort interruptions only? If that was ruled out as worse (two flags to keep in sync), fine. I'd just like it stated.

Nitpicking: test_worker_failure_after_timed_deadline_is_partial relies on the late-drop peer sleeping 1.3s, past --test-time=1, while the run is still waiting for the reply. It's fine today, but if the drain grace changes, the test could start testing something else without failing. A short comment tying the 1.3 to the drain grace would help whoever touches that next.

The core fix looks solid. I'd mainly want the Interrupted semantics change called out explicitly before this merges.

(would file this as a comment, not a formal block)

@fcostaoliveira

Copy link
Copy Markdown
Collaborator Author

The final description now explicitly calls out the metadata change for single-run ALL STATS as well as per-run, selected, and aggregate output. README documents that failed workers also mark the run interrupted. The existing injected-exception tests now require that single-run flag, and all three exception/fatal-cleanup controls pass. Worker failure detection and exit codes stay unchanged; ordinary command errors and natural zero-operation timed completion remain eligible.

I considered keeping ranking validity separate. failed_threads is local to run_benchmark, while ranking happens later over stored run objects; that would require additional per-run validity state and would leave an already-invalid single-run result labeled uninterrupted. This change deliberately preserves the existing failure classification in the result's current interruption flag. Issue #796 records that separate metadata defect and its affected history.

The 1.3-second drop is after the one-second deadline but before the current ten-second drain grace. The test requires exit 1, exactly three completed replies, and Interrupted: true; if normal drain expiry won instead, its exit 0/unchanged interruption flag would fail those assertions rather than silently exercise a different path.

@fcostaoliveira
fcostaoliveira merged commit 86ffb63 into master Oct 23, 2026
136 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant