Skip to content

make graph data lazy for reused binary lists#3132

Draft
cornmander wants to merge 2 commits intonextest-rs:mainfrom
cornmander:codex/lazy-baseapp-binary-list
Draft

make graph data lazy for reused binary lists#3132
cornmander wants to merge 2 commits intonextest-rs:mainfrom
cornmander:codex/lazy-baseapp-binary-list

Conversation

@cornmander
Copy link
Contributor

fixes #3128.

summary

This change delays loading the Cargo package graph until it is actually needed, instead of constructing it in BaseApp::new unconditionally.

For cargo nextest list --list-type binaries-only with reused --binaries-metadata, that means nextest can skip cargo metadata and the PackageGraph in the common fast path, resolve the workspace root with cargo locate-project, and still preserve the existing diagnostics for CLI filter parsing.

The normal non-reused list path is not materially changed by this patch.

performance

Benchmarks were run with warm caches on macOS (aarch64-apple-darwin) using hyperfine, comparing origin/main with this branch.

  • tokio (e67cd87, 264 binaries): 121.6 ms ± 2.3 ms -> 52.8 ms ± 0.8 ms for nextest list --list-type binaries-only --binaries-metadata ... --message-format json.
  • tokio: 2.30x faster, or about 56.5% lower wall time.
  • rust-analyzer (51966da, 68 binaries): 174.7 ms ± 9.6 ms -> 57.3 ms ± 1.5 ms for the same command.
  • rust-analyzer: 3.05x faster, or about 67.2% lower wall time.

The avoided Cargo startup cost lines up with the improvement:

  • tokio: cargo metadata --format-version=1 --all-features --filter-platform aarch64-apple-darwin was 87.2 ms ± 3.5 ms, while cargo locate-project --workspace --message-format plain was 39.6 ms ± 0.7 ms.
  • rust-analyzer: the same commands were 122.5 ms ± 5.7 ms and 45.5 ms ± 2.4 ms.

testing

  • cargo xfmt --check
  • cargo check -p cargo-nextest -p integration-tests
  • cargo nextest run -p cargo-nextest
  • cargo nextest run -p integration-tests -E 'test(test_list_binaries_only) or test(test_list_binaries_only_after_build) or test(test_list_full_after_build) or test(test_list_host_after_build) or test(test_list_target_after_build)'

…-rs#3128)

Delay loading the cargo metadata graph until it is actually needed, and let the reused binaries-only list path discover the workspace root without constructing the full package graph up front.

This keeps the normal behavior intact while cutting startup cost for list --list-type binaries-only with --binaries-metadata. Also add integration coverage for the reused binaries-only path.
Collapse a nested if in manifest_path_for_build() so the lint job passes on CI.
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 0% with 226 lines in your changes missing coverage. Please review.
✅ Project coverage is 0.88%. Comparing base (9531cb9) to head (9575ed0).
⚠️ Report is 90 commits behind head on main.

Files with missing lines Patch % Lines
cargo-nextest/src/dispatch/core/base.rs 0.00% 123 Missing ⚠️
cargo-nextest/src/dispatch/core/list.rs 0.00% 59 Missing ⚠️
cargo-nextest/src/dispatch/helpers.rs 0.00% 31 Missing ⚠️
cargo-nextest/src/dispatch/core/run.rs 0.00% 9 Missing ⚠️
cargo-nextest/src/dispatch/core/archive.rs 0.00% 4 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (9531cb9) and HEAD (9575ed0). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (9531cb9) HEAD (9575ed0)
2 1
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #3132       +/-   ##
==========================================
- Coverage   84.43%   0.88%   -83.55%     
==========================================
  Files         156     152        -4     
  Lines       42733   42009      -724     
==========================================
- Hits        36080     371    -35709     
- Misses       6653   41638    +34985     

☔ 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.

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.

optimize cargo nextest list --list-type binaries-only to avoid unnecessary setup work

1 participant