Skip to content

Comments

[nextest-runner] skip loading output for replays unless necessary#3090

Merged
sunshowers merged 1 commit intomainfrom
skip-loading
Feb 22, 2026
Merged

[nextest-runner] skip loading output for replays unless necessary#3090
sunshowers merged 1 commit intomainfrom
skip-loading

Conversation

@sunshowers
Copy link
Member

Measured this against a 727 test run locally -- time cargo nextest replay > /dev/null dropped from 0.15s to 0.135s.

We use a pure function with a conservative approximation to avoid having to track the cancel reason and other less relevant facts.

The property-based tests ensure the invariants.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes cargo nextest replay by skipping decompression/loading of recorded test output when reporter configuration guarantees the output will never be displayed, while keeping the decision logic conservative and validated via property tests.

Changes:

  • Introduces OutputLoadDecider to conservatively decide whether a replayed output event needs its output bytes loaded.
  • Adds a NotLoaded output variant during replay conversion and wires a per-event LoadOutput decision through replay conversion.
  • Refactors output description types: OutputSpec now uses ChildOutputDesc, and recordings use the new ZipStoreOutputDescription (separate from live output).

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
nextest-runner/src/reporter/structured/libtest.rs Handles the new NotLoaded output variant defensively (unreachable in live libtest reporting).
nextest-runner/src/reporter/mod.rs Re-exports OutputLoadDecider for replay callers.
nextest-runner/src/reporter/events.rs Refactors output description generics (ChildOutputDesc) and adds ChildOutputDescription::NotLoaded.
nextest-runner/src/reporter/error_description.rs Adds NotLoaded match arm with invariant-based unreachable!.
nextest-runner/src/reporter/displayer/unit_output.rs Factors output display overrides and adds NotLoaded match arm with invariant-based unreachable!.
nextest-runner/src/reporter/displayer/status_level.rs Adds proptests establishing safety invariants for skipping output loads during replay.
nextest-runner/src/reporter/displayer/mod.rs Re-exports OutputLoadDecider.
nextest-runner/src/reporter/displayer/imp.rs Implements OutputLoadDecider and wires overrides through displayer logic.
nextest-runner/src/reporter/aggregator/junit.rs Handles NotLoaded output variant defensively (unreachable in live JUnit reporting).
nextest-runner/src/record/summary.rs Introduces ZipStoreOutputDescription for recorded output metadata and updates generic bounds to ChildOutputDesc.
nextest-runner/src/record/rerun.rs Updates tests to use ZipStoreOutputDescription.
nextest-runner/src/record/replay.rs Adds LoadOutput, threads it through conversion, and returns NotLoaded when skipping output loads.
nextest-runner/src/record/recorder.rs Converts live ChildOutputDescription into ZipStoreOutputDescription and asserts NotLoaded is impossible during recording.
nextest-runner/src/record/mod.rs Re-exports LoadOutput and ZipStoreOutputDescription.
nextest-runner/src/output_spec.rs Renames associated type to ChildOutputDesc and maps Live/Recording specs to the new description types.
cargo-nextest/src/dispatch/core/replay.rs Computes LoadOutput per event via OutputLoadDecider and passes it into replay conversion.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 662 to 666
if baseline.store_final == OutputStoreFinal::No {
assert_eq!(
with_cancel.store_final,
OutputStoreFinal::No,
"cancel_status={cancel_status:?} caused final output storage that \
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In cancellation_only_hides_output, the final-output monotonicity check only covers the baseline.store_final == OutputStoreFinal::No case. Consider also asserting that if baseline.store_final is Yes { display_output: false } then with_cancel.store_final never becomes Yes { display_output: true } (i.e. cancellation never causes output bytes to be displayed at the end). This would better enforce the stated invariant and protect against future changes to compute_output_on_test_finished that might accidentally flip display_output from false to true.

Copilot uses AI. Check for mistakes.
Measured this against a 727 test run locally -- `time cargo nextest replay > /dev/null` dropped from 0.15s to 0.135s.

We use a pure function with a conservative approximation to avoid having to track the cancel reason and other less relevant facts.

The property-based tests ensure the invariants.
@codecov
Copy link

codecov bot commented Feb 22, 2026

Codecov Report

❌ Patch coverage is 93.86503% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.27%. Comparing base (78c6cbd) to head (929829e).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
nextest-runner/src/record/recorder.rs 78.57% 3 Missing ⚠️
nextest-runner/src/record/replay.rs 92.85% 2 Missing ⚠️
nextest-runner/src/reporter/aggregator/junit.rs 0.00% 1 Missing ⚠️
...xtest-runner/src/reporter/displayer/unit_output.rs 97.56% 1 Missing ⚠️
nextest-runner/src/reporter/error_description.rs 0.00% 1 Missing ⚠️
nextest-runner/src/reporter/events.rs 0.00% 1 Missing ⚠️
nextest-runner/src/reporter/structured/libtest.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3090      +/-   ##
==========================================
- Coverage   84.27%   84.27%   -0.01%     
==========================================
  Files         156      156              
  Lines       42446    42536      +90     
==========================================
+ Hits        35772    35847      +75     
- Misses       6674     6689      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sunshowers sunshowers merged commit ac25b4d into main Feb 22, 2026
23 checks passed
@sunshowers sunshowers deleted the skip-loading branch February 22, 2026 10:14
@trunk-io
Copy link

trunk-io bot commented Feb 22, 2026

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant