Skip to content

Commit dfd1908

Browse files
authored
Use pytest-xdist --dist worksteal option to speed up Pytest runs (#8366)
The pytest-xdist module has options to control dynamic workload distribution. The default does not always produce the fastest run times. Some exploration of alternatives revealed that using the option `--dist worksteal` yields faster pytest runs. The "worksteal" mode reassigns tests from less busy workers to idle ones to optimize fixture reuse and handle varying test durations. In worksteal mode, when a worker is nearly idle (fewer than two tests left in its queue), it "steals" pending tests from busier workers. This PR adds the option `--dist worksteal` to `tool.pytest.ini_options` in `pyproject.toml`. This results in an almost 25% improvement in execution time over the default pytest-xdist value for the dist option (which is `--dist load`).
1 parent ca684ed commit dfd1908

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎pyproject.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,10 @@ ignore_missing_imports = true
128128

129129

130130
[tool.pytest.ini_options]
131-
addopts = ["--benchmark-disable"]
131+
addopts = [
132+
"--benchmark-disable",
133+
"--dist=worksteal",
134+
]
132135
filterwarnings = [
133136
"ignore:Matplotlib is currently using agg:UserWarning",
134137
"ignore:FigureCanvasAgg is non-interactive.*cannot be shown:UserWarning",

0 commit comments

Comments
 (0)