Skip to content

perf(tests): share git-source fixture, drop pixi-run-git overhead#6033

Merged
baszalmstra merged 1 commit intoprefix-dev:mainfrom
baszalmstra:perf-pytest-share-git-fixture
May 6, 2026
Merged

perf(tests): share git-source fixture, drop pixi-run-git overhead#6033
baszalmstra merged 1 commit intoprefix-dev:mainfrom
baszalmstra:perf-pytest-share-git-fixture

Conversation

@baszalmstra
Copy link
Copy Markdown
Contributor

@baszalmstra baszalmstra commented May 6, 2026

Description

Speeds up tests/integration_python/pixi_build/test_specified_build_source/test_git.py.

  • local_cpp_git_repo is now scope="session". 7 of the 8 tests don't mutate the repo, so they can share one initialization.
  • The fixture uses system git instead of pixi run git, which previously had to materialize the workspace's pixi env on every invocation just to spawn git from PATH.
  • The one test that pushes commits into the repo (test_git_path_build_has_absolutely_no_respect_to_lock_file) now uses a separate function-scoped local_cpp_git_repo_mutable fixture so the shared repo stays read-only for everyone else.

How Has This Been Tested?

CI Windows, slowest-durations entries for these tests:

Phase Before After
setup test_git_path_lock_branch_records_branch_metadata 44.26s dropped from list
setup test_git_path_build_has_absolutely_no_respect_to_lock_file 42.55s dropped from list
setup test_git_path_build 34.52s dropped from list
setup test_git_path_lock_consistent_across_platforms 30.54s dropped from list
setup test_git_path_lock_tag_records_tag_metadata 29.11s dropped from list
setup test_git_path_lock_update_preserves_git_source 22.86s dropped from list
setup test_git_path_lock_rev_marks_explicit_rev 21.62s dropped from list
setup test_git_path_lock_detects_manual_rev_change 21.14s dropped from list
Sum of setup 246.6s ~0s in slowest-50
call test_git_path_build 12.34s 36.23s*
call test_git_path_lock_branch_records_branch_metadata 18.47s 16.74s
call test_git_path_build_has_absolutely_no_respect_to_lock_file 25.12s 15.56s
call test_git_path_lock_tag_records_tag_metadata 19.98s 10.52s

*the first test's call now absorbs the one-time session-fixture cost.

Net CI Windows saving on this file: ~243s, dominated by per-test setup elimination.

Local Windows (debug build), full file: 257.6s → 59.9s.

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code (Opus 4.7).

Checklist:

  • I have performed a self-review of my own code
  • I have added sufficient tests to cover my changes.

Cuts test_git.py from 257.6s to 59.9s (-77%).

- local_cpp_git_repo is now scope=session and uses system git instead
  of 'pixi run git', avoiding the per-test workspace env materialization.
- test_git_path_build_has_absolutely_no_respect_to_lock_file gets its
  own local_cpp_git_repo_mutable fixture so the session-scoped repo
  stays read-only for the other 7 tests.
- Setup time across 8 tests drops from 176s to 2.6s; the mutating
  test's call time drops from 24.6s to 12.1s.
@baszalmstra baszalmstra force-pushed the perf-pytest-share-git-fixture branch from 1cc6798 to 3565ac3 Compare May 6, 2026 18:39
@baszalmstra baszalmstra requested review from hunger and ruben-arts May 6, 2026 19:05
@hunger
Copy link
Copy Markdown
Contributor

hunger commented May 6, 2026

I do not have git on my system... but in the project environment that is active. As I read the code that is fine still, just wanted to double-check.

@baszalmstra baszalmstra merged commit 6a9380e into prefix-dev:main May 6, 2026
39 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.

2 participants