Repository navigation
Run each output read on its own thread, so held output can't starve new programs - #69
Merged
Merged
Conversation
A program left holding its output open kept a pool thread blocked per stream. Once those reached the pool's minimum, a new program's reads queued behind them while the pool grew a thread at a time, so they hit the stream timeout and came back empty. PkStreamReadTask now starts with TaskCreationOptions.LongRunning, which gives each read a dedicated thread. TypesVersion goes to 8: the C# changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Earlier sections raise the harness's own pool minimum, and lowering it again doesn't bring back the slow growth the test depends on, so the test runs in a child PowerShell with the default minimum. Its holders are found by parent PID and killed, with one overall wait for their reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 18, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
Each output read ran on a thread-pool thread and blocked there until the stream closed. A program that leaves something running with its output open (a
cmd /c start /b ...) keeps that read, and its pool thread, busy until the leftover lets go. Once those reads used up the pool's minimum (128 by default), a new program's reads queued behind them while the pool added a thread at a time. They hit the stream timeout and came back empty withStreamTimedOut, even for a plainecho. 3.2 behaved the same way.What changed
PkStreamReadTaskstarts withTaskCreationOptions.LongRunning, so each read gets a thread of its own instead of a pool thread. A held stream still costs one thread until the leftover lets go; it no longer holds up other programs' output.[PkState]::TypesVersiongoes to 8, since the C# changed: a session that loaded an older copy has to start a new PowerShell window.Initialize-PkThreadPoolstill raises the pool's minimum. Only its comment changed, since the reads no longer depend on it.StreamTimedOutparagraph says what a held stream costs.How it was tested
New harness section AZ runs in a fresh PowerShell, because earlier sections raise the harness's own pool minimum. It starts enough programs that each leave a
pingholding stdout and stderr to go past the pool's minimum: 84 at the default 128. Then it runscmd /c echo plainwith a 5 s stream timeout. Afterwards it kills only the pings its owncmds started (found by parent PID) and checks all their reads end.On the old code (main), full harness on Windows PowerShell 5.1, only the new assertion fails:
Section AZ alone on the old code, PowerShell 7: the same failure (
'', StreamTimedOut=True, 5.07 s).With this change, on both runtimes:
Full harness: Windows PowerShell 5.1
ALL PASSED (552 assertions), PowerShell 7ALL PASSED (552 assertions).🤖 Generated with Claude Code