Skip to content

perf(ci): run tests in parallel via pytest-xdist - #45

Merged
ManSio merged 1 commit into
mainfrom
perf/ci-pytest-xdist
Sep 26, 2026
Merged

ManSio merged 1 commit into
mainfrom
perf/ci-pytest-xdist

Conversation

@ManSio

@ManSio ManSio commented Sep 26, 2026

Copy link
Copy Markdown
Owner

What

The CI test job ran serially (ubuntu 13m44s, windows 16m34s). It now runs pytest-xdist with -n auto.

Measurement (local, 12 cores, 1865 tests)

run wall
baseline serial (no cov) 197.1s
-n auto (no cov) 71.4s (x2.76)
-n auto + coverage (CI shape) 86.4s

All green: 1865 passed, 5 skipped, coverage 54.58% (gate 38%).

Quality preserved

  • Same test command on both OSes — ubuntu+windows matrix is unchanged, no tests deselected.
  • -n auto only parallelizes; no marker exclusions, no --exitfirst, no sharding.

Coverage config

The local .coveragerc sets dynamic_context=test_function (per-test contexts used by the bootstrap pipeline), which pytest-cov rejects under xdist (DistCovError, pytest-cov#604) and which costs ~+13.6% (sys.settrace, AGENT_DIARY 2026-09-15). CI only needs the --cov-fail-under gate, so it now uses the shipped context-free .coveragerc.ci via COVERAGE_RCFILE. Local/bootstrap runs keep .coveragerc (still gitignored).

Also

  • tests/test_temporal_facts_generator.py: the three tests shared one deterministic dataset but each re-ran generate(seed=7) (dozens of git subprocesses). A module-scoped fixture cuts it 36.6s -> 20.8s. test_deterministic_generation still calls generate twice on purpose.

Deps

  • Added pytest-xdist>=3.5.0 to the dev extra.

The test job ran serially (13m44s on ubuntu). pytest-xdist -n auto cuts
the local suite from 197s to 71s (x2.76 on 12 cores); CI runners have 4
cores, so the job time drops proportionally. Both OSes keep the exact
same test command, so coverage of ubuntu+windows is unchanged.

Coverage moves to .coveragerc.ci (COVERAGE_RCFILE): the local
.coveragerc sets dynamic_context=test_function, which pytest-cov rejects
under xdist (DistCovError, pytest-cov#604) and which costs ~+13.6%
(sys.settrace, AGENT_DIARY 2026-09-15). CI only needs the % gate, so it
uses the context-free config; local and bootstrap runs keep contexts.

Also cache the temporal facts generator per module (36.6s -> 20.8s): the
three tests share one deterministic dataset but each re-ran generate(),
which spawns dozens of git subprocesses.

Measured locally (12 cores): serial 197.1s -> xdist 71.4s (no cov) ->
xdist + ci-cov 86.4s; 1865 passed, coverage 54.58% (> 38% gate).
@coderabbitai

coderabbitai Bot commented Sep 26, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 5ad055db-71a0-4284-8e6a-45f293201ce9


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ManSio
ManSio merged commit 5a2213e into main Sep 26, 2026
12 of 13 checks passed
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