Repository navigation
perf(windows): read the process table natively instead of forking PowerShell - #15749
Merged
Merged
Conversation
nwparker
force-pushed
the
nwparker/w1b-windows-process-table
branch
4 times, most recently
from
August 22, 2026 04:10
af3e36d to
3bd9e68
Compare
|
Too many files changed for review (174 files, 100 file limit). Bypass the limit by tagging |
…erShell Seven independent readers each forked powershell.exe to run Get-CimInstance Win32_Process, with a wmic fallback that Windows 11 24H2 has removed. On a domain-joined host with PowerShell Transcription enabled by policy, one of them running every ~2s recorded ~289GB across 1.4 million files (#15209). The same scan cost ~700ms and ran per pane (#15036), and a Group Policy or AV block turned it into 'unavailable', which callers read as 'no evidence' -- which is how a PTY tree survives its own teardown (#9045, #10475). A Toolhelp32 snapshot answers the same question with no child process. Measured on Windows 11 with 1050 processes, p50/p95: pid+ppid+name 15.9 / 17.5 ms +memory +command line 30.6 / 33.7 ms Get-CimInstance 706 / 723 ms Two upstream defects needed patching, both found by running it on real hardware. The binding requires Spectre-mitigated libraries our agents do not carry (node-pty is patched the same way). And enumeration stopped after 1024 processes: on a host with 1051 the module returned exactly 1024, and the querying process was itself among the 27 missing -- a truncated snapshot silently hides the descendants teardown is looking for, which is the failure this whole change exists to remove. Migrated: the foreground/descendant reader (the #15209 scraper and the teardown identity gate) and the port scanner's PID attribution. NOT migrated: the memory collector and three identity probes, which need Win32_Process.CreationDate and have no native equivalent. Start time is a proxy for identity anyway; an inherited job handle is the real answer, so those belong with the job-object work rather than here. Packaging follows the windows-native-registry contract exactly: optional, absent from onlyBuiltDependencies so macOS/Linux never run node-gyp, win32-only in the packaged runtime. Asserted by the existing contract test, which also stops pinning a whole source literal that only tested its own formatting.
windows-foreground-process-rows.ts no longer spawns anything, so its allowlist line is stale. The guard fails on a stale entry as well as a new one, precisely so a migrated file cannot keep a slot open and hide the next regression in the same path.
Missing import: the migration replaced the PowerShell call but the new symbol was never imported, so tsc failed. Vitest transpiles without typechecking, which is why the port-scanner suite stayed green.
Same class as the fix on the tip branch: pnpm records a hash per patched dependency, and this branch introduces the windows-process-tree patch without its lockfile entry matching. Every job here failed at install with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Verified with --frozen-lockfile, which is what CI runs and what my local runs were not.
Two relay cases fed a PowerShell CIM payload through a mocked execFile. That reader is gone, so both failed -- deterministically, on every PR run for this branch and the one above it. I did not catch it because my own verification sweep was 'src/main src/shared config/scripts' and never included src/relay. The relay is a first-class consumer of the process table; leaving it out of the sweep is how a deterministic failure survived six review rounds.
nwparker
force-pushed
the
nwparker/w1b-windows-process-table
branch
from
August 22, 2026 04:21
3bd9e68 to
08c3d08
Compare
nwparker
changed the base branch from
nwparker/w2-process-spawn-chokepoint
to
main
August 22, 2026 04:32
This was referenced Aug 22, 2026
Contributor
Author
|
Merged to Closed by this stack: #10488, #15209, #9045, #10475, #10897, #9195, #10415. Commented, not closed — partially addressed or needing a reporter re-test: #14543, #11771, #15036, #10686, #10087, #8275, #10150, #10358, #10857. Withdrawn: #15549 — I claimed it early and hardware testing disproved it. Job liveness reports Windows CI now gates the argv encoder against real |
This was referenced Aug 22, 2026
Closed
8 of 9 tasks
paidaxingyo666
pushed a commit
to paidaxingyo666/Manta
that referenced
this pull request
Aug 23, 2026
…erShell (stablyai#15749) * perf(windows): read the process table natively instead of forking PowerShell Seven independent readers each forked powershell.exe to run Get-CimInstance Win32_Process, with a wmic fallback that Windows 11 24H2 has removed. On a domain-joined host with PowerShell Transcription enabled by policy, one of them running every ~2s recorded ~289GB across 1.4 million files (stablyai#15209). The same scan cost ~700ms and ran per pane (stablyai#15036), and a Group Policy or AV block turned it into 'unavailable', which callers read as 'no evidence' -- which is how a PTY tree survives its own teardown (stablyai#9045, stablyai#10475). A Toolhelp32 snapshot answers the same question with no child process. Measured on Windows 11 with 1050 processes, p50/p95: pid+ppid+name 15.9 / 17.5 ms +memory +command line 30.6 / 33.7 ms Get-CimInstance 706 / 723 ms Two upstream defects needed patching, both found by running it on real hardware. The binding requires Spectre-mitigated libraries our agents do not carry (node-pty is patched the same way). And enumeration stopped after 1024 processes: on a host with 1051 the module returned exactly 1024, and the querying process was itself among the 27 missing -- a truncated snapshot silently hides the descendants teardown is looking for, which is the failure this whole change exists to remove. Migrated: the foreground/descendant reader (the stablyai#15209 scraper and the teardown identity gate) and the port scanner's PID attribution. NOT migrated: the memory collector and three identity probes, which need Win32_Process.CreationDate and have no native equivalent. Start time is a proxy for identity anyway; an inherited job handle is the real answer, so those belong with the job-object work rather than here. Packaging follows the windows-native-registry contract exactly: optional, absent from onlyBuiltDependencies so macOS/Linux never run node-gyp, win32-only in the packaged runtime. Asserted by the existing contract test, which also stops pinning a whole source literal that only tested its own formatting. * chore(process): ratchet the child_process allowlist down windows-foreground-process-rows.ts no longer spawns anything, so its allowlist line is stale. The guard fails on a stale entry as well as a new one, precisely so a migrated file cannot keep a slot open and hide the next regression in the same path. * fix(ports): import the process-table reader the scanner uses Missing import: the migration replaced the PowerShell call but the new symbol was never imported, so tsc failed. Vitest transpiles without typechecking, which is why the port-scanner suite stayed green. * fix(deps): sync this branch's lockfile with its patch set Same class as the fix on the tip branch: pnpm records a hash per patched dependency, and this branch introduces the windows-process-tree patch without its lockfile entry matching. Every job here failed at install with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Verified with --frozen-lockfile, which is what CI runs and what my local runs were not. * test(relay): drive the relay's Windows fixtures from the native snapshot Two relay cases fed a PowerShell CIM payload through a mocked execFile. That reader is gone, so both failed -- deterministically, on every PR run for this branch and the one above it. I did not catch it because my own verification sweep was 'src/main src/shared config/scripts' and never included src/relay. The relay is a first-class consumer of the process table; leaving it out of the sweep is how a deterministic failure survived six review rounds. (cherry picked from commit 057fbfc)
This was referenced Aug 25, 2026
fix(memory): report the Windows number that predicts paging, not just resident pages (#16211)
#16589
Merged
dallascrilley
pushed a commit
to dallascrilley/orca
that referenced
this pull request
Aug 27, 2026
…erShell (stablyai#15749) * perf(windows): read the process table natively instead of forking PowerShell Seven independent readers each forked powershell.exe to run Get-CimInstance Win32_Process, with a wmic fallback that Windows 11 24H2 has removed. On a domain-joined host with PowerShell Transcription enabled by policy, one of them running every ~2s recorded ~289GB across 1.4 million files (stablyai#15209). The same scan cost ~700ms and ran per pane (stablyai#15036), and a Group Policy or AV block turned it into 'unavailable', which callers read as 'no evidence' -- which is how a PTY tree survives its own teardown (stablyai#9045, stablyai#10475). A Toolhelp32 snapshot answers the same question with no child process. Measured on Windows 11 with 1050 processes, p50/p95: pid+ppid+name 15.9 / 17.5 ms +memory +command line 30.6 / 33.7 ms Get-CimInstance 706 / 723 ms Two upstream defects needed patching, both found by running it on real hardware. The binding requires Spectre-mitigated libraries our agents do not carry (node-pty is patched the same way). And enumeration stopped after 1024 processes: on a host with 1051 the module returned exactly 1024, and the querying process was itself among the 27 missing -- a truncated snapshot silently hides the descendants teardown is looking for, which is the failure this whole change exists to remove. Migrated: the foreground/descendant reader (the stablyai#15209 scraper and the teardown identity gate) and the port scanner's PID attribution. NOT migrated: the memory collector and three identity probes, which need Win32_Process.CreationDate and have no native equivalent. Start time is a proxy for identity anyway; an inherited job handle is the real answer, so those belong with the job-object work rather than here. Packaging follows the windows-native-registry contract exactly: optional, absent from onlyBuiltDependencies so macOS/Linux never run node-gyp, win32-only in the packaged runtime. Asserted by the existing contract test, which also stops pinning a whole source literal that only tested its own formatting. * chore(process): ratchet the child_process allowlist down windows-foreground-process-rows.ts no longer spawns anything, so its allowlist line is stale. The guard fails on a stale entry as well as a new one, precisely so a migrated file cannot keep a slot open and hide the next regression in the same path. * fix(ports): import the process-table reader the scanner uses Missing import: the migration replaced the PowerShell call but the new symbol was never imported, so tsc failed. Vitest transpiles without typechecking, which is why the port-scanner suite stayed green. * fix(deps): sync this branch's lockfile with its patch set Same class as the fix on the tip branch: pnpm records a hash per patched dependency, and this branch introduces the windows-process-tree patch without its lockfile entry matching. Every job here failed at install with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Verified with --frozen-lockfile, which is what CI runs and what my local runs were not. * test(relay): drive the relay's Windows fixtures from the native snapshot Two relay cases fed a PowerShell CIM payload through a mocked execFile. That reader is gone, so both failed -- deterministically, on every PR run for this branch and the one above it. I did not catch it because my own verification sweep was 'src/main src/shared config/scripts' and never included src/relay. The relay is a first-class consumer of the process table; leaving it out of the sweep is how a deterministic failure survived six review rounds.
OrcaWin
pushed a commit
that referenced
this pull request
Sep 8, 2026
The relocated daemon host mirrors the install dir, but the manifest copied only node-pty out of resources/node_modules. `@vscode/windows-process-tree` was never copied, so `require` failed inside orca-terminal-daemon.exe, `readOneSnapshot` took the absent-module branch, and every process-table read fell through to `powershell.exe Get-CimInstance Win32_Process`. That is #16905. The transcript pasted in the issue is byte-identical to POWERSHELL_PROCESS_QUERY, not to the memory collector's query -- which is also why toggling Resource Manager off changed nothing. The foreground tracker refreshes on the renderer's 2s agent-completion poll, so it ran about once per agent pane per two seconds, indefinitely. Copy the addon's runtime surface (package.json, lib/, the .node) into the mirror, and hash the addon into the materialization marker so a host missing or carrying a stale one is re-materialized rather than used: a host that cannot load it still runs, and silently forks a shell per snapshot, which is the failure this is fixing. Check the addon exists before the copy, not after -- the marker hashes it, so otherwise a ~260MB copy runs and is discarded when the hash throws, on every launch. Absence still fails open to the install-dir host, which has it. Finally, warn once when the CIM fallback engages. Absence is legitimate on a relay; being quiet about it is how this lasted months. Fixes #16905. Related to #15209 and #15749.
OrcaWin
pushed a commit
that referenced
this pull request
Sep 8, 2026
The relocated daemon host mirrors the install dir, but the manifest copied only node-pty out of resources/node_modules. `@vscode/windows-process-tree` was never copied, so `require` failed inside orca-terminal-daemon.exe, `readOneSnapshot` took the absent-module branch, and every process-table read fell through to `powershell.exe Get-CimInstance Win32_Process`. That is #16905. The transcript pasted in the issue is byte-identical to POWERSHELL_PROCESS_QUERY, not to the memory collector's query -- which is also why toggling Resource Manager off changed nothing. The foreground tracker refreshes on the renderer's 2s agent-completion poll, so it ran about once per agent pane per two seconds, indefinitely. Copy the addon's runtime surface (package.json, lib/, the .node) into the mirror, and hash the addon into the materialization marker so a host missing or carrying a stale one is re-materialized rather than used: a host that cannot load it still runs, and silently forks a shell per snapshot, which is the failure this is fixing. Check the addon exists before the copy, not after -- the marker hashes it, so otherwise a ~260MB copy runs and is discarded when the hash throws, on every launch. Absence still fails open to the install-dir host, which has it. Finally, warn once when the CIM fallback engages. Absence is legitimate on a relay; being quiet about it is how this lasted months. Fixes #16905. Related to #15209 and #15749.
OrcaWin
pushed a commit
that referenced
this pull request
Sep 8, 2026
The relocated daemon host mirrors the install dir, but the manifest copied only node-pty out of resources/node_modules. `@vscode/windows-process-tree` was never copied, so `require` failed inside orca-terminal-daemon.exe, `readOneSnapshot` took the absent-module branch, and every process-table read fell through to `powershell.exe Get-CimInstance Win32_Process`. That is #16905. The transcript pasted in the issue is byte-identical to POWERSHELL_PROCESS_QUERY, not to the memory collector's query -- which is also why toggling Resource Manager off changed nothing. The foreground tracker refreshes on the renderer's 2s agent-completion poll, so it ran about once per agent pane per two seconds, indefinitely. Copy the addon's runtime surface (package.json, lib/, the .node) into the mirror, and hash the addon into the materialization marker so a host missing or carrying a stale one is re-materialized rather than used: a host that cannot load it still runs, and silently forks a shell per snapshot, which is the failure this is fixing. Check the addon exists before the copy, not after -- the marker hashes it, so otherwise a ~260MB copy runs and is discarded when the hash throws, on every launch. Absence still fails open to the install-dir host, which has it. Finally, warn once when the CIM fallback engages. Absence is legitimate on a relay; being quiet about it is how this lasted months. Fixes #16905. Related to #15209 and #15749.
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…erShell (stablyai#15749) * perf(windows): read the process table natively instead of forking PowerShell Seven independent readers each forked powershell.exe to run Get-CimInstance Win32_Process, with a wmic fallback that Windows 11 24H2 has removed. On a domain-joined host with PowerShell Transcription enabled by policy, one of them running every ~2s recorded ~289GB across 1.4 million files (stablyai#15209). The same scan cost ~700ms and ran per pane (stablyai#15036), and a Group Policy or AV block turned it into 'unavailable', which callers read as 'no evidence' -- which is how a PTY tree survives its own teardown (stablyai#9045, stablyai#10475). A Toolhelp32 snapshot answers the same question with no child process. Measured on Windows 11 with 1050 processes, p50/p95: pid+ppid+name 15.9 / 17.5 ms +memory +command line 30.6 / 33.7 ms Get-CimInstance 706 / 723 ms Two upstream defects needed patching, both found by running it on real hardware. The binding requires Spectre-mitigated libraries our agents do not carry (node-pty is patched the same way). And enumeration stopped after 1024 processes: on a host with 1051 the module returned exactly 1024, and the querying process was itself among the 27 missing -- a truncated snapshot silently hides the descendants teardown is looking for, which is the failure this whole change exists to remove. Migrated: the foreground/descendant reader (the stablyai#15209 scraper and the teardown identity gate) and the port scanner's PID attribution. NOT migrated: the memory collector and three identity probes, which need Win32_Process.CreationDate and have no native equivalent. Start time is a proxy for identity anyway; an inherited job handle is the real answer, so those belong with the job-object work rather than here. Packaging follows the windows-native-registry contract exactly: optional, absent from onlyBuiltDependencies so macOS/Linux never run node-gyp, win32-only in the packaged runtime. Asserted by the existing contract test, which also stops pinning a whole source literal that only tested its own formatting. * chore(process): ratchet the child_process allowlist down windows-foreground-process-rows.ts no longer spawns anything, so its allowlist line is stale. The guard fails on a stale entry as well as a new one, precisely so a migrated file cannot keep a slot open and hide the next regression in the same path. * fix(ports): import the process-table reader the scanner uses Missing import: the migration replaced the PowerShell call but the new symbol was never imported, so tsc failed. Vitest transpiles without typechecking, which is why the port-scanner suite stayed green. * fix(deps): sync this branch's lockfile with its patch set Same class as the fix on the tip branch: pnpm records a hash per patched dependency, and this branch introduces the windows-process-tree patch without its lockfile entry matching. Every job here failed at install with ERR_PNPM_LOCKFILE_CONFIG_MISMATCH. Verified with --frozen-lockfile, which is what CI runs and what my local runs were not. * test(relay): drive the relay's Windows fixtures from the native snapshot Two relay cases fed a PowerShell CIM payload through a mocked execFile. That reader is gone, so both failed -- deterministically, on every PR run for this branch and the one above it. I did not catch it because my own verification sweep was 'src/main src/shared config/scripts' and never included src/relay. The relay is a first-class consumer of the process table; leaving it out of the sweep is how a deterministic failure survived six review rounds.
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.
Why
Seven independent readers each forked
powershell.exeto runGet-CimInstance Win32_Process, with awmicfallback that Windows 11 24H2 has removed. Node can't read parent-PIDs on Windows without native code, which is why they all existed.That shape produced several unrelated-looking bugs:
windows-foreground-process-rows.ts.A Toolhelp32 snapshot answers the same question with no child process at all, so none of those failure modes have anywhere to live.
Measured on real hardware
Windows 11, 1050 processes, same box, p50 / p95:
Get-CimInstancevia PowerShell (today)~44× on the path that currently sits behind a 3-second timeout during teardown.
Two upstream defects, both found by running it
Neither shows up in the docs; both came out of a spike on a real box.
binding.gyprequires Spectre-mitigated libraries our Windows agents don't install — build fails withMSB8040.node-ptyis patched the same way for the same reason.GetRawProcessListstopped after 1024 entries. On a host with 1051 processes it returned exactly 1024, and the querying process was itself among the 27 missing —getProcessList(self)failed outright. A truncated snapshot silently hides the descendants a teardown is looking for. That is precisely the bug class this change exists to remove, so adopting the package unpatched would have reimported it.Both are one-line hunks in
config/patches/@[email protected].Also worth recording: the typings say
commandLineis truncated at 512 chars. Measured, it isn't — longest observed was 26,059. That risk is closed, not worked around.Scope — what is deliberately not migrated
daemon-process-inspection,daemon-process-identity-query,managed-hook-owner-identity) readWin32_Process.CreationDate, which has no native equivalent.getProcessCpuUsage()is not adopted: it takes both CPU samples inside one call with a blockingSleep(1000), which would hold a libuv threadpool slot for a full second out of the Resource Manager's two-second poll. Given [Bug]: Terminal intermittently stops accepting text input #8104, that's not a trade worth making.Start time is a proxy for identity. For trees Orca itself spawned, an inherited job handle is the real answer, so those readers belong with the job-object change rather than here.
docs/reference/windows-process-enumeration.mdrecords that reasoning so the next person doesn't just bolt a start time onto the facade.Tests
child_processto the module seam. Cases that became unrepresentable were deleted, not neutered — "falls back to WMIC when PowerShell fails" and "the probe passeswindowsHide" no longer describe anything real. Scan-volume bounds were kept and now count snapshots.Packaging
Follows the
windows-native-registrycontract exactly:optionalDependency, absent fromonlyBuiltDependencies(pnpm installs optional deps on every host, so macOS/Linux must never runnode-gypfor a Windows addon), win32-only in the packaged runtime. VerifiedcreatePackagedRuntimeNodeModuleResourcesemits it for win32 and not for darwin/linux.Issues
Closes #15209. Materially addresses #15036 and #10686. Removes the probe-failure mode behind #9045 and #10475 — the kill decision itself is the next PR.