Repository navigation
Conversation
_kill_existing_processes scanned every process on the machine with psutil and pulled cmdline and cwd for each, which costs ~100-150ms on a busy host even though only node processes can be running pglite_manager.js. Filter on the process name first and fetch cmdline/cwd lazily for the few node processes, and skip the scan entirely when the work directory was auto-created (a brand new temp dir cannot have a stale process).
This branch has not been deployed
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.
Summary
_kill_existing_processesruns on everyPGliteManager.start(). It usedpsutil.process_iter(["pid", "name", "cmdline", "cwd"])and inspected every process on the host;process_iterfetches the requested attributes eagerly, so on a busy machine (~2300 processes) it costs ~150ms per start even though nothing matches.pglite_manager.js. Filter onnamefirst and fetchcmdline/cwdlazily for those few processes (measured ~98ms on the same host, with only a couple of processes actually probed).tempfile.mkdtemp()is brand new, so no process can have it as its working directory.Semantics for a reused work directory are unchanged: a node process running
pglite_manager.jswith cwd equal to the work directory is still killed.Testing
tests/test_manager_comprehensive.pyfor the lazy probing, and added cases: an auto-created work dir skips the scan, unrelated node processes are ignored, and unreadable process names are handled safely.pytest tests/test_manager_comprehensive.py tests/test_enhanced_process_cleanup.py -m "not slow"→ 59 passed.