⚡ perf(test): parallelize test suite with pytest-xdist - #3035
Merged
Conversation
The test suite ran serially at ~74s. Adding pytest-xdist with `-n auto --dist loadfile` distributes tests across CPU cores while keeping same-file tests together for efficient session-fixture reuse. The existing coverage infrastructure (coverage-enable-subprocess, COVERAGE_PROCESS_START, coverage combine) already handles subprocess coverage, so no additional wiring was needed. Also skip pip seeding in test_create_long_path since it only validates long path support, and reduce the per-test timeout from 600s to 120s since the slowest test takes ~6s. Wall-clock time drops from ~74s to ~26s.
gaborbernat
marked this pull request as ready for review
February 15, 2026 16:24
gaborbernat
enabled auto-merge (squash)
February 15, 2026 16:24
This was referenced Mar 12, 2026
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.
The test suite runs all 420 tests serially, taking ~74s on a modern machine. For a project where CI runs across many Python versions, this adds up quickly. 🕐
This adds
pytest-xdistand configures tox to run tests with-n auto --dist loadfile. Theautoflag scales workers to available CPU cores, whileloadfilekeeps tests from the same file on the same worker so session-scoped fixtures (likeactivation_pythonwhich creates a shared venv) aren't needlessly recreated. The existing coverage infrastructure —coverage-enable-subprocess,COVERAGE_PROCESS_START, andcoverage combine— already handles subprocess coverage collection, so no additional wiring was needed.Also removes unnecessary pip seeding from
test_create_long_path(it only validates long path support, not pip) and reduces the per-test timeout from 600s to 120s since the slowest test takes ~6s. ⚡ Wall-clock time drops from ~74s to ~26s with no change in test results or coverage.