Skip to content

Optimize CI performance with sccache and Windows dev drive#2190

Open
wolfv wants to merge 6 commits intomainfrom
claude/speed-up-windows-tests-5QeGJ
Open

Optimize CI performance with sccache and Windows dev drive#2190
wolfv wants to merge 6 commits intomainfrom
claude/speed-up-windows-tests-5QeGJ

Conversation

@wolfv
Copy link
Member

@wolfv wolfv commented Feb 20, 2026

Summary

This PR improves CI performance by implementing compiler caching with sccache on main branch builds and leveraging Windows ReFS dev drives for significantly faster I/O operations during builds.

Key Changes

  • Sccache integration: Added RUSTC_WRAPPER=sccache environment variable for main branch builds only, with PR builds continuing to use the existing Swatinem/rust-cache. This seeds the sccache cache on main while avoiding cache thrashing from PR builds.
  • Windows dev drive setup: Added samypr100/setup-dev-drive action to create a 10GB ReFS dev drive on Windows runners, providing ~30x faster I/O compared to the standard C: drive.
  • Environment mapping: Configured CARGO_HOME, RUSTUP_HOME, and temporary directories to use the dev drive for optimal performance.
  • Target directory redirection: Created junctions to redirect cargo build artifacts to the dev drive:
    • test job: redirects target directory
    • release job: redirects target-pixi directory (matching pixi's CARGO_TARGET_DIR configuration)
  • Applied to both jobs: All optimizations were applied to both the test and release CI jobs for consistent performance improvements.

Implementation Details

  • Sccache is only enabled on main branch (github.ref == 'refs/heads/main') to avoid unnecessary cache operations in PR builds
  • Windows-specific steps use conditional execution (if: runner.os == 'Windows') to avoid errors on Linux/macOS runners
  • Dev drive setup includes explicit directory creation and junction creation with -Force flag for reliability

https://claude.ai/code/session_012DzrboBAeV8z9BT8EYn1Sd

Use samypr100/setup-dev-drive to create a ReFS-formatted virtual disk
on Windows runners. The C: drive on GitHub-hosted Windows runners does
~4,262 IOPS while a ReFS VHDX achieves ~127,823 IOPS (~30x faster).

For both the `test` and `build-and-test` jobs:
- Move CARGO_HOME and RUSTUP_HOME to the dev drive via env-mapping
- Create a filesystem junction for the cargo target directory so it
  transparently redirects to the dev drive (avoids conflicts with
  pixi's CARGO_TARGET_DIR activation and Swatinem/rust-cache paths)

https://claude.ai/code/session_012DzrboBAeV8z9BT8EYn1Sd
- Redirect TMP and TEMP to the ReFS dev drive on Windows so pytest
  tmp_path and other temp file operations also benefit from faster I/O
- Add mozilla-actions/sccache-action for compilation caching, only
  active on main branch pushes (RUSTC_WRAPPER is empty on PRs so
  there is zero overhead); main builds seed the sccache, PRs continue
  to rely on Swatinem/rust-cache

https://claude.ai/code/session_012DzrboBAeV8z9BT8EYn1Sd
Fix ensure-pinned-actions CI check by replacing version tags with
commit SHAs for setup-dev-drive and sccache-action.

https://claude.ai/code/session_012DzrboBAeV8z9BT8EYn1Sd
PowerShell's New-Item -ItemType Junction requires the target directory
to exist. Create them on the dev drive first, and pipe output to
Out-Null to avoid pipeline noise under $ErrorActionPreference = 'Stop'.

https://claude.ai/code/session_012DzrboBAeV8z9BT8EYn1Sd
The TMP/TEMP redirect to ReFS likely causes test failures due to
filesystem behavior differences between ReFS and NTFS. Remove it —
the main performance wins come from the target directory junction and
CARGO_HOME/RUSTUP_HOME on the dev drive anyway.

https://claude.ai/code/session_012DzrboBAeV8z9BT8EYn1Sd
10GB was too small — a debug build target dir alone can be 15-20GB,
and RUSTUP_HOME + CARGO_HOME add another 2GB+. Bump to 50GB (the
VHDX is dynamic so it only consumes actual disk space as needed).

Also remove RUSTUP_HOME from the dev drive: the toolchain is installed
once then only read from, so it doesn't benefit much from faster I/O
and just wastes space on the VHDX.

https://claude.ai/code/session_012DzrboBAeV8z9BT8EYn1Sd
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