Skip to content

perf(tests): per-worker template repo cuts Windows CI fixture cost - #43

Merged
pbean merged 1 commit into
mainfrom
perf/template-repo-fixture
Jul 3, 2026
Merged

perf(tests): per-worker template repo cuts Windows CI fixture cost#43
pbean merged 1 commit into
mainfrom
perf/template-repo-fixture

Conversation

@pbean

@pbean pbean commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Why

Follow-up to #42. Windows test jobs only scaled ~1.5× under xdist (265s vs 412s serial): the project fixture git-inits a fresh repo per test — 5 subprocess spawns × 412 tests — and on Windows that's ~3s of setup per test (slow process spawn + fsync, 4 workers contending on disk). The --durations table on the #42 run showed exactly this: ~3s setup entries for test_verify_worktree/test_cli/test_engine.

What

tests/conftest.py only:

  • New session-scoped _project_template fixture builds the identical sandbox once per xdist worker (same files, same 5 git commands, identity kept in local config so copies inherit it).
  • project now shutil.copytrees the template — zero git spawns per test (~25 small files, tens of ms on Windows).
  • core.fsync=none in the template's local config, inherited by copies and their worktrees, cheapening the ~100 remaining inline add/commit calls.

Safety, verified against the code

  • No phantom-dirty from the copied index: all cleanliness checks in verify.py are porcelain (status --porcelain, git diff --quiet, OID compare, throwaway GIT_INDEX_FILE) which re-hash stat-dirty entries; diff-index/diff-files plumbing appears nowhere. Also proven empirically: a copytree'd repo reports clean porcelain status.
  • Fresh non-worktree repos contain no absolute paths → fully relocatable; .git/worktrees/* is created per-copy, so the real git worktree add tests are unaffected.
  • All rev_parse_head assertions are same-repo; identical initial SHAs across copies are harmless.
  • The identity-unset test (test_verify.py) --unsets local config, which the copy carries exactly as before.

Verified locally

Full suite green serial (1321 passed, 108s — down from ~125s) and 3× under -n 4/-n auto (28–33s). Targeted canaries green: identity-unset + finalize-commit + commit-paths, all worktree suites (103 passed), ledger-commit suites (77 passed). --durations=15 now shows no setup entries at all. trunk check clean.

Expected on this PR's Windows jobs: test phase ~265s → ~100–150s. The one ~3s template build per worker shows up on whichever test runs first — by design.

🤖 Generated with Claude Code

…d of git-initing per test

The project fixture spawned 5 git subprocesses per test x 412 tests; on
Windows CI that cost ~3s of setup per test and capped the xdist speedup at
~1.5x (4 workers contending on slow process spawn + fsync). A session-scoped
template (one build per xdist worker) copytree'd per test drops that to zero
spawns; core.fsync=none in the template's local config is inherited by
copies and their worktrees, cheapening the remaining inline commits.

Copied repos verified clean (porcelain status/diff re-hash the stat-dirty
index) and fully relocatable (no absolute paths in a fresh non-worktree
repo); identity stays local config so the identity-unset test and ledger
commit helpers behave unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@pbean, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 25 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d40a64e5-4e9e-4b22-bc04-be72449abfea

📥 Commits

Reviewing files that changed from the base of the PR and between e940e15 and d52365e.

📒 Files selected for processing (1)
  • tests/conftest.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/template-repo-fixture

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.

@augmentcode

augmentcode Bot commented Jul 3, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

Summary: Refactors the project test fixture to build a sandbox git repo template once per pytest session/xdist worker and copy it per test, eliminating expensive Windows setup.

Changes: Introduces a session-scoped _project_template and makes project use shutil.copytree, inheriting local git config (identity + core.fsync=none) into each disposable test repo.

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

@pbean
pbean merged commit af81b6d into main Jul 3, 2026
9 checks passed
@pbean
pbean deleted the perf/template-repo-fixture branch July 3, 2026 02:54
@pbean pbean mentioned this pull request Jul 3, 2026
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