mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3789] [Other] procs.py: Windows engine start 5.6 s sooner by improving orphan search (6.2 -> 0.1 s) #4783
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4783
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3789
Author: @page1
Created: 10/23/2026
Status: 🔄 Open
Base:
main← Head:fix/orphan-scan-windows📝 Commits (1)
0a11fbdserve (Windows): the orphan search before an engine start lists processes by command line only (6.2 s -> 0.1 s)📊 Changes
1 file changed (+9 additions, -3 deletions)
View changed files
📝
strata_control/procs.py(+9 -3)📄 Description
Problem and result
Before every engine start, the server looks for engines that an earlier run left behind
(
strata_control/procs.py,orphans_of). The search asks psutil for every process's parent and start time whilelisting processes. On Windows, psutil reads a process's parent from a snapshot of the whole system, once per process,
and falls back to another whole-system snapshot for the start time of every process where
OpenProcessis denied(system and other accounts' processes). With 474 processes running (207 of them access-denied), the search took
6.1-6.5 s; with more programs open, 8.4-8.9 s. The server is a fresh process at every
start, so nothing is cached, and the engine waits that long before it is launched.
After the change the search takes 0.10 s, and the engine is launched 5.6 s sooner.
Related discussion
A focused fix, no issue; it came up while timing engine starts for #2672. #3254 (open) also changes
strata_control/procs.py: which ancestors count as starters, and howend_one()waits. This PR changes only howthe processes are listed, and the two merge without conflicts (
git merge-treeof both heads).Approach
--servefrom this executable: normally none, atmost the orphan itself.
can't be read counts as unknown, as before (
process_itergaveNonefor it). One difference: a candidate whosestart time can't be read is now skipped; in 0.2.2 it gave
None + 1.0, aTypeErrorthat ended the whole search./procand were already cheap; there the change only stops readingthem for processes that aren't candidates.
Validation
Passed: (at
0a11fbd9, which is 0.2.2011c9e60plus this commit)On Windows 11 26300 (Python 3.13, psutil 7.2.2, 474 processes running), RTX 3090, Core Ultra 9 285K, IQ3_S at 262K,
with the same 0.2.2 engine before and after:
procs.end_orphans()(the function the server calls before each start), in a fresh Python processstrata.execreatedThe two server-start rows are one start each way (every server and engine line and every new child process
timestamped every 50 ms), so the 5.6 s in the title has n = 1; the search time it removes is the 3 + 3 row. This is
one of a series of Windows start-time changes: the engine-side ones in #2672 were measured more thoroughly there
(8 + 8 + 8 and 10 + 10 engine starts, and 3 + 3 server starts together with this fix).
Command for the first row, from the repo root:
python -m unittest tests.terminal.test_procs: 7/7. Its orphan test starts a real orphan and checks that it isfound and ended, and that a process with a live parent is not.
python -m unittest tests.terminal.test_cloudflared_find tests.terminal.test_file_in_use tests.terminal.test_models_move serve.test_lifeline: the same results as on 0.2.2 (49 tests, 8 skipped eitherway).
Failed: none observed.
Not run: Linux and macOS. The changed function runs there too, with fewer lookups; I have no Linux or Mac
machine to run the tests on. If anyone on Linux or macOS can run
python -m unittest tests.terminal.test_procsonthis branch, I'd appreciate the confirmation.
Limits
The time saved grows with the number of processes running: a PC with a browser and many apps open saves more.
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.