-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Process.children() is slow #1183
Comments
Hey Antoine! =) Lines 862 to 864 in 3a3598e
We can't get away from that. With that said, it is true that we're doing more than just that because we also call We can probably avoid that and define a utility function similar to what we have on windows: Lines 851 to 854 in 3a3598e
...which just returns a {pid; ppid, ...} map for all processes in one shot.
|
Does that function have to be consistent? The problem is if the processes change while iterating on e.g. |
A process which "changes" while iterating means it will disappear, in which case we'll just skip it. |
I see, so we can just scan quickly over |
Yes. Same goes for all other platforms except Windows which already does this in C. |
This makes Process.children() 3x faster when there are no children.
it can spawns more threads than cpu cores in some case, but that's OK the idea is to spawn tasks as subprocesses within threads so we count the threads of the subprocesses (and not our threads) it can spawns more threads than cpu cores because an heavy task can be spawned right after another heavy one was spawned but hasn't found the time to spawn its core itself, is usually only happens on very first tasks when nothing is already running Process.children() is very slow, see: giampaolo/psutil#1183 it's highly recommended to use python3-psutil >= 5.4.2 because some great speed-up were implemented
It seems half of that is calling
process_iter()
:The text was updated successfully, but these errors were encountered: