fix(server): terminal subprocess polling no longer floods the PID space - #25
Merged
Conversation
…ce (#6377) (cherry picked from commit 80991402dcdc488838fb4d8b21171bd38d9ab0aa)
Thread transfer impact
This comment will update automatically after the next completed run. |
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.
Adopts upstream
#6377. Terminal subprocess polling spawned a process per terminal, per poll at a 1s cadence —pgreppluspson POSIX,powershell.exeon Windows. Several open terminals churned through PIDs fast enough to matter, and PID exhaustion is not confined to Pylon when it happens.What changed
psreads the whole table;deriveSubprocessInspectResultthen walks each terminal's subtree from that snapshot in memory. Per-poll spawns go from O(terminals × commands) to O(1).pgrepis gone entirely — the snapshot already answers what it was asked, so that's one fewer spawn per terminal per poll.psresolves to an absolute path once at startup. Spawning by bare name walks everyPATHentry, costing one failedposix_spawnper directory until the hit — measurable at a 1s cadence on a longPATH.This lands squarely on Pylon's "performance without compromise" line, and it's a defect with blast radius outside the app rather than a tidy-up.
Verification
vp test run apps/server/src/terminal/Manager.test.ts: 54 passed (the commit brings 120 lines of new tests with it).vp run -F t3 typecheck: no errors.vp linton both changed files: clean.Clean cherry-pick — no Pylon adaptation needed, and no conflict with anything Pylon has diverged on here.
Not exercised end-to-end against a live terminal with several sessions open; the behaviour is covered by the unit tests rather than an integration pass.
Model: Claude Opus 5. Harness: Claude Code.
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.