Skip to content

Commit cad5bd9

Browse files
committed
CI: use a Dev Drive to improve Windows I/O performance
Dev Drives are a modern Windows feature based on the ReFS file system which offers significantly better performance for developer-focused workloads. This is perfect for pip's Windows CI which is still slower than the Unix jobs. Most of the implementation was borrowed from the uv project which also uses a Dev Drive to improve their Windows CI times. There is a community action (samypr100/setup-dev-drive) that can set up a Dev Drive for us, but the Powershell script needed for our simple needs is really not that bad. The small maintenance burden of doing it ourselves is perferable over the risks of using yet another 3rd party action. NB: We used to use a RAM disk to improve I/O performance, but the creation of the RAM disk started to fail intermittently, annoying everyone and eliminating any speed ups gained by the constant retrying needed. See also: https://learn.microsoft.com/en-us/windows/dev-drive/
1 parent 3b91f42 commit cad5bd9

File tree

2 files changed

+54
-19
lines changed

2 files changed

+54
-19
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,15 @@ jobs:
112112
strategy:
113113
fail-fast: true
114114
matrix:
115-
os: [ubuntu-latest, macos-13, macos-latest]
115+
os: [ubuntu-latest]
116+
# os: [ubuntu-latest, macos-13, macos-latest]
116117
python:
117118
- "3.8"
118-
- "3.9"
119-
- "3.10"
120-
- "3.11"
121-
- "3.12"
122-
- "3.13"
119+
# - "3.9"
120+
# - "3.10"
121+
# - "3.11"
122+
# - "3.12"
123+
# - "3.13"
123124

124125
steps:
125126
- uses: actions/checkout@v4
@@ -162,7 +163,7 @@ jobs:
162163
name: tests / ${{ matrix.python }} / ${{ matrix.os }} / ${{ matrix.group }}
163164
runs-on: ${{ matrix.os }}-latest
164165

165-
needs: [packaging, determine-changes]
166+
needs: [determine-changes]
166167
if: >-
167168
needs.determine-changes.outputs.tests == 'true' ||
168169
github.event_name != 'pull_request'
@@ -189,41 +190,36 @@ jobs:
189190
python-version: ${{ matrix.python }}
190191
allow-prereleases: true
191192

192-
# We use C:\Temp (which is already available on the worker)
193-
# as a temporary directory for all of the tests because the
194-
# default value (under the user dir) is more deeply nested
195-
# and causes tests to fail with "path too long" errors.
193+
- name: Create a Dev Drive
194+
run: |
195+
./tools/ci/devdrive.ps1 -Drive R -Size 5GB
196+
mkdir R:\Temp
197+
echo "TEMP=R:\\Temp" >> $env:GITHUB_ENV
198+
196199
- run: pip install nox
197-
env:
198-
TEMP: "C:\\Temp"
199200

200201
# Main check
201202
- name: Run unit tests
202203
if: matrix.group == 1
203204
run: >-
205+
echo $TEMP
204206
nox -s test-${{ matrix.python }} --
205207
-m unit
206208
--verbose --numprocesses auto --showlocals
207-
env:
208-
TEMP: "C:\\Temp"
209209
210210
- name: Run integration tests (group 1)
211211
if: matrix.group == 1
212212
run: >-
213213
nox -s test-${{ matrix.python }} --
214214
-m integration -k "not test_install"
215215
--verbose --numprocesses auto --showlocals
216-
env:
217-
TEMP: "C:\\Temp"
218216
219217
- name: Run integration tests (group 2)
220218
if: matrix.group == 2
221219
run: >-
222220
nox -s test-${{ matrix.python }} --
223221
-m integration -k "test_install"
224222
--verbose --numprocesses auto --showlocals
225-
env:
226-
TEMP: "C:\\Temp"
227223
228224
tests-zipapp:
229225
name: tests / zipapp

tools/ci/devdrive.ps1

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# A Powershell script to create a Dev Drive which tends to have significantly better
2+
# performance in developer workloads. The goal is improve pip's Windows CI times.
3+
#
4+
# The implementation was borrowed from the uv project which also use a Dev Drive for
5+
# better CI performance: https://github.com/astral-sh/uv/pull/3522
6+
#
7+
# Windows docs:
8+
# https://learn.microsoft.com/en-us/windows/dev-drive/
9+
# Related GHA reports:
10+
# https://github.com/actions/runner-images/issues/7320 (Windows slowness report)
11+
# https://github.com/actions/runner-images/issues/8698 (feature request for
12+
# preprovisioned Dev Drives)
13+
14+
[CmdletBinding()]
15+
param(
16+
[Parameter(Mandatory=$true,
17+
HelpMessage="Drive letter to use for the Dev Drive")]
18+
[String]$drive,
19+
[Parameter(Mandatory=$true,
20+
HelpMessage="Size to allocate to the Dev Drive")]
21+
[UInt64]$size
22+
)
23+
$ErrorActionPreference = "Stop"
24+
25+
$OSVersion = [Environment]::OSVersion.Version
26+
$Partition = New-VHD -Path C:/pip_dev_drive.vhdx -SizeBytes $size |
27+
Mount-VHD -Passthru |
28+
Initialize-Disk -Passthru |
29+
New-Partition -DriveLetter $drive -UseMaximumSize
30+
# Dev Drives aren't supported on all GHA Windows runners, in which case fallback to
31+
# a ReFS disk which still offer performance gains.
32+
if ($OSVersion -ge (New-Object 'Version' 10.0.22621)) {
33+
Write-Output "Dev Drives are supported, one will be created at $drive:"
34+
$Volume = ($Partition | Format-Volume -DevDrive -Confirm:$false -Force)
35+
} else {
36+
Write-Output "Dev Drives are unsupported, only creating a ReFS disk at $drive:"
37+
$Volume = ($Partition | Format-Volume -FileSystem ReFS -Confirm:$false -Force)
38+
}
39+
Write-Output $Volume

0 commit comments

Comments
 (0)