Skip to content

Leave the thread pool's minimum alone - #76

Merged
HalRiveria-Bot merged 2 commits into
mainfrom
fix/leave-thread-pool
Nov 19, 2026
Merged

HalRiveria-Bot merged 2 commits into
mainfrom
fix/leave-thread-pool

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

What was wrong

Initialize-ParallelKit, the first Start-PkProcess and every Invoke-PkProcessDispatch raised the process-wide thread pool minimum: to at least 128 worker threads, or 2 x -MaxConcurrent + 32. That was for the output reads, which used to block pool threads. Since #69 each read has a thread of its own, so the kit no longer needs it, and the minimum is a setting the caller's own code shares.

What changed

  • The kit no longer touches the thread pool's settings. Initialize-PkThreadPool is gone, along with its calls from Start-PkProcessCore and the dispatcher.
  • Initialize-ParallelKit still returns ThreadPool (always $true) and still takes -MaxConcurrentProcesses (now unused), so existing scripts keep working.
  • Help text and README updated. The README's setup snippet drops -MaxConcurrentProcesses 8.
  • [PkState]::ThreadPoolRaised is now unused. It stays for now because removing it is a C# change.

How it was tested

  • Measured before the change, on a copy with SetMinThreads taken out (minimum 16) against the raised one (128). Five alternating fresh-process rounds per runtime showed no difference:
    • 400 quick programs at 64 at once: 3.3-3.5 s on 5.1, 4.05-4.17 s on 7, either way.
    • 200 runspace jobs of 300 ms at 64: 1.54-1.66 s and 1.41-1.46 s.
    • 500 instant runspace jobs: about 0.6 s and 0.5 s.
    • 100 programs next to 60 leftover programs holding their output: 0.46-0.56 s and about 0.6 s.
    • No output missing anywhere.
  • The four assertions that checked the raise now check that the minimum is left alone: after Initialize-ParallelKit, after a first Start-PkProcess in a fresh process, and after the dispatcher at -MaxConcurrent 100 and with a shared budget of 150.
  • On the old code those four fail on both runtimes (128/232/332 against 16). On this branch the full harness passed on 5.1 and then 7: 594 assertions each.

🤖 Generated with Claude Code

HalRiveria and others added 2 commits November 19, 2026 02:15
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit 7444c0e into main Nov 19, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the fix/leave-thread-pool branch November 19, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants