|
| 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