1- param([switch]$RunBashCommand)
1+ # Raises a process to normal I/O priority; the processes it starts afterwards inherit it. The
2+ # self-hosted Windows runners start steps at Low, which the driver and the browsers inherit, and
3+ # Firefox storage flushes then stall until the tests time out (microsoft/playwright#43704).
4+ # Dot-source it at the start of a pwsh step to raise that step's shell, or run it with -ProcessId
5+ # from another shell, as exec.sh does for its own Git Bash process before it runs the command.
6+ param([int]$ProcessId = $PID)
27
38$ErrorActionPreference = 'Stop'
49
@@ -17,31 +22,27 @@ public static class TestProcessIOPriority {
1722}
1823'@
1924
25+ $process = [System.Diagnostics.Process]::GetProcessById($ProcessId)
2026$priority = 0
2127$length = 0
2228$status = [TestProcessIOPriority]::NtQueryInformationProcess(
23- [IntPtr](-1) , 33, [ref]$priority, 4, [ref]$length)
29+ $process.Handle , 33, [ref]$priority, 4, [ref]$length)
2430if ($status -ne 0) {
2531 throw ('Reading I/O priority failed: NTSTATUS 0x{0:X8}' -f $status)
2632}
2733$inheritedPriority = $priority
2834$priority = 2
2935$status = [TestProcessIOPriority]::NtSetInformationProcess(
30- [IntPtr](-1) , 33, [ref]$priority, 4)
36+ $process.Handle , 33, [ref]$priority, 4)
3137if ($status -ne 0) {
3238 throw ('Setting normal I/O priority failed: NTSTATUS 0x{0:X8}' -f $status)
3339}
3440$status = [TestProcessIOPriority]::NtQueryInformationProcess(
35- [IntPtr](-1) , 33, [ref]$priority, 4, [ref]$length)
41+ $process.Handle , 33, [ref]$priority, 4, [ref]$length)
3642if ($status -ne 0) {
3743 throw ('Reading I/O priority failed: NTSTATUS 0x{0:X8}' -f $status)
3844}
3945if ($priority -ne 2) {
4046 throw "Expected normal I/O priority (2), got $priority"
4147}
42- Write-Host "Test launcher I/O priority: $inheritedPriority -> $priority (Normal)"
43-
44- if ($RunBashCommand) {
45- & "$env:ProgramFiles\Git\bin\bash.exe" --noprofile --norc -eo pipefail -c $env:PW_TEST_COMMAND
46- exit $LASTEXITCODE
47- }
48+ Write-Host "I/O priority of $($process.ProcessName) (${ProcessId}): $inheritedPriority -> $priority (Normal)"
0 commit comments