Tracking Child Processes (tree of child processes)
See original GitHub issueI’ve noticed that when using subprocess.run
on my dask tasks, the workers still report low CPU usage, when the child process is in fact maxing out my CPU usage. Does Dask track the forked/child process CPU usage under the worker CPU usage? If not, I think it should since child processes can occur when interfacing dask workers against programs written in non-python.
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Track Child Processes Using strace | Baeldung on Linux
A quick and practical guide to tracking child processes with strace.
Read more >unix - I need to trace all child processes created by given ...
Use exec strace -s 9999 -f -e trace=execve -p [pid of process] >& strace.log . Then parse it with some simple perl script...
Read more >linux - Find child processes created by a Command?
Is there a way in Linux to check the child processes created by a command? I am running a command and it completes...
Read more >Cb Response: How many child processes are shown in...
The process tree can only display up to 15 child processes; either 15 unsuppressed, 15 suppressed, or 15 of both types. For processes...
Read more >ProcExp: Process Explorer: Viewing Parent and Child Processes
The unique capabilities of Process Explorer make it useful for tracking down DLL-version problems or ... Notice the Parent / Child Process Tree...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is natively supported in the
psutil
package: https://unix.stackexchange.com/a/339071/56970The
True
ensures that it gets it recursively.https://psutil.readthedocs.io/en/latest/#psutil.Process.children
Another way is to realise that process group on Linux will always encapsulate the entire process tree when launched by a shell. See: https://en.wikipedia.org/wiki/Process_group This means that on Linux, if you start each worker on its own process group. Then you can just query the PGID and get all processes part of that group. This is also useful for distribution of signals. However this may not be portable to Windows or other operating systems, whereas process tree via direct descendants may be more standard among all OS.
I wrote a gist about this process groups: https://gist.github.com/CMCDragonkai/f58afb7e39fcc422097849b853caa140
I tried to find a solution to follow the workers’ child processes.
To do this, the class handling the system monitoring must track the children; otherwise, the CPU usage is always 0 for all children (no previous time exists to calculate the usage). Initially, the children’s set is empty. Then we have to add new children and remove the old ones. In short, it adds a little bit of calculation. In my test case, I didn’t see any problem with the monitoring performance.
I can open a PR to insert this change.