-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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/
- Loading branch information
Showing
2 changed files
with
54 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# A Powershell script to create a Dev Drive which tends to have significantly better | ||
# performance in developer workloads. The goal is improve pip's Windows CI times. | ||
# | ||
# The implementation was borrowed from the uv project which also use a Dev Drive for | ||
# better CI performance: https://github.com/astral-sh/uv/pull/3522 | ||
# | ||
# Windows docs: | ||
# https://learn.microsoft.com/en-us/windows/dev-drive/ | ||
# Related GHA reports: | ||
# https://github.com/actions/runner-images/issues/7320 (Windows slowness report) | ||
# https://github.com/actions/runner-images/issues/8698 (feature request for | ||
# preprovisioned Dev Drives) | ||
|
||
[CmdletBinding()] | ||
param( | ||
[Parameter(Mandatory=$true, | ||
HelpMessage="Drive letter to use for the Dev Drive")] | ||
[String]$drive, | ||
[Parameter(Mandatory=$true, | ||
HelpMessage="Size to allocate to the Dev Drive")] | ||
[UInt64]$size | ||
) | ||
$ErrorActionPreference = "Stop" | ||
|
||
$OSVersion = [Environment]::OSVersion.Version | ||
$Partition = New-VHD -Path C:/pip_dev_drive.vhdx -SizeBytes $size | | ||
Mount-VHD -Passthru | | ||
Initialize-Disk -Passthru | | ||
New-Partition -DriveLetter $drive -UseMaximumSize | ||
# Dev Drives aren't supported on all GHA Windows runners, in which case fallback to | ||
# a ReFS disk which still offer performance gains. | ||
if ($OSVersion -ge (New-Object 'Version' 10.0.22621)) { | ||
Write-Output "Dev Drives are supported, one will be created at $drive:" | ||
$Volume = ($Partition | Format-Volume -DevDrive -Confirm:$false -Force) | ||
} else { | ||
Write-Output "Dev Drives are unsupported, only creating a ReFS disk at $drive:" | ||
$Volume = ($Partition | Format-Volume -FileSystem ReFS -Confirm:$false -Force) | ||
} | ||
Write-Output $Volume |