Skip to content

Speed up CI, especially the Windows matrix - #74

Merged
duncankmckinnon merged 2 commits into
mainfrom
ci/speed-up-windows
Sep 11, 2026
Merged

Speed up CI, especially the Windows matrix#74
duncankmckinnon merged 2 commits into
mainfrom
ci/speed-up-windows

Conversation

@duncankmckinnon

Copy link
Copy Markdown
Owner

Why

Windows CI runs the suite in ~265-300s vs ~65s on Ubuntu (~4x). Under load this recently tipped a fixed 30s subprocess timeout in test_store_concurrency.py into a flaky failure on PR #70 (run).

Changes

  • pytest-xdist + -n auto — distributes tests across the runner's cores. Locally: full suite ~25s serial → ~7-9s parallel (with or without coverage), 2720 passed both ways, no cross-test contamination found.
  • Skip coverage instrumentation on Windows — only the ubuntu-latest, 3.12 leg's coverage is uploaded (see the Upload coverage reports to Codecov step's if:), so the other five matrix legs, including three of the four Ubuntu ones, were paying the instrumentation cost for nothing. -o addopts= clears pyproject's default --cov flags for the Windows invocation only; Ubuntu keeps coverage as before, now also parallelized.
  • cache: pip on actions/setup-python, keyed on pyproject.toml — cuts most of the ~55s dependency install.

Verified locally

pytest tests/ -n auto -o addopts="" -q   → 2720 passed, 2 xpassed in 6.6s
pytest tests/ -n auto --cov-report=xml   → 2720 passed, 2 xpassed in 9.3s, coverage.xml written

ruff clean, workflow YAML validated.

Doesn't change test semantics or the matrix's version coverage — a follow-up could additionally right-size the heaviest concurrency tests' iteration counts or trim the Windows matrix to one Python version, if this isn't enough on its own.

🤖 Generated with Claude Code

duncankmckinnon and others added 2 commits September 11, 2026 10:09
Windows CI runs the suite in ~265-300s vs ~65s on Ubuntu (~4x), largely
concentrated in file-concurrency tests hitting the Windows fsops
retry-on-PermissionError path, plus a long tail of thousands of tests
each somewhat slower (atomic writes, msvcrt locks, real subprocess
spawns in test_e2e_*). Under load this recently tipped a fixed 30s
subprocess timeout in test_store_concurrency.py into a flaky failure.

- pytest-xdist + `-n auto`: distributes tests across the runner's cores.
  Locally, full suite: ~25s serial -> ~7-9s parallel, no cross-test
  contamination (2720 passed either way).
- Skip coverage instrumentation on Windows: only ubuntu/3.12's coverage
  is uploaded, so the other five matrix legs -- ubuntu included -- were
  paying for it with nothing to show. `-o addopts=` clears pyproject's
  default `--cov` flags for the Windows invocation.
- Cache pip downloads via actions/setup-python's `cache: pip`.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
pushed run: windows-latest/3.13 regressed under -n auto -- slower
overall (347s vs the ~298s pre-xdist baseline) and still hit the
pre-existing "writer timed out" flake, this time in a different test in
the same file.

test_store_concurrency.py spawns 8 real Python subprocesses itself and
asserts they finish within a fixed deadline. Under -n auto those 8
processes now also compete with three other xdist worker processes for
the runner's CPU -- more contention than serial execution had, not
less. Run that file outside the parallel pool so it gets the runner to
itself; everything else still parallelizes.

Also widen _WRITER_TIMEOUT 30 -> 90 for margin: this test's assumption
of near-dedicated CPU to start 8 interpreters and contend for one file
lock doesn't hold reliably on shared Windows CI runners even in
isolation.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@duncankmckinnon
duncankmckinnon merged commit 7806c5f into main Sep 11, 2026
7 checks passed
@duncankmckinnon
duncankmckinnon deleted the ci/speed-up-windows branch September 11, 2026 17:28
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