Use both pytest-split and pytest-xdist for parallel CPU test execution#2868
Merged
copybara-service[bot] merged 1 commit intomainfrom Dec 22, 2025
Merged
Use both pytest-split and pytest-xdist for parallel CPU test execution#2868copybara-service[bot] merged 1 commit intomainfrom
copybara-service[bot] merged 1 commit intomainfrom
Conversation
ebb7729 to
aee108a
Compare
165809d to
4b82901
Compare
6b7bdd6 to
2f0138e
Compare
Previously, CPU tests are distributed across multiple workers using pytest-split, which assigns the same number of tests to each worker. However, since the runtime of tests is different, some workers end up finishing fast and stand idle while others take a long time, so we're not utilizing the workers fully. This change replaces the use of pytest-split with pytest-xdist which dynamically assigns work to workers.
NicoGrande
approved these changes
Dec 22, 2025
gobbleturk
approved these changes
Dec 22, 2025
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.
Previously, CPU tests are distributed across multiple runners using pytest-split, which assigns the same number of tests to each worker. However, since the runtime of tests is different and each runner gets few tests, some workers end up finishing fast and stand idle while others take a long time, so we're not utilizing the workers fully. In addition, only one process is used within each runner, despite many CPUs available.
In this PR we're still statically splitting the CPU tests across multiple runners using pytest-split, but we're reducing the number to 2 instead of 4 (so each runner gets more tests), and now also utilizing multiple concurrent processes and dynamically assigning work to these processes within each runner using pytest-xdist.
Overall, we're reducing the number of runners from 4 to 2, the runners are now well balanced and finish approximately at the same time (since each gets assigned more tests) and slightly reduce the total CPU test run time by ~20sec.
If CPU tests become a bottleneck just add another runner to the matrix.
Tests
Testing in CI.
Checklist
Before submitting this PR, please make sure (put X in square brackets):
gemini-reviewlabel.