node-tree-kill
node-tree-kill copied to clipboard
Consider using pidtree package
Currently this package recursively kill processes level by level spawning the ps
or pgrep
a lot of times.
I've built this package that maybe can help to improve performance. https://github.com/simonepri/pidtree
My benchmarks shows that is really fast (~5-10 ms per call regardless of how big the sub-tree is) but I don't know if it would be adapt for the use of this package.
What's the advantage of calling ps
or pgrep
multiple times instead of parsing the tree just calling ps
once? Memory efficiency? Or it was just simpler to implement?
See also: https://github.com/Unitech/pm2/pull/3554#issuecomment-374758938
cc: @soyuka
linux freebsd netbsd sunos macos win aix ✅ ❓ ❓ ❓ ✅ ✅ ❓ ✅ = Working ❓ = Not tested but should work
:astonished: That's amazing! I'm guessing @pkrumins wrote it that way because, that's just what he thought up at the time? I'd be interested in a PR that replaces the current logic with 'pidtree'. We would have to release it as a semver major version, though just in case. (When you have over 100,000 downloads a day and zero regression tests... it's good to be cautious.)
Edit: Hah I just saw that https://github.com/Unitech/pm2/pull/3554/files basically IS such a PR. Very interesting!
Hah I just saw that https://github.com/Unitech/pm2/pull/3554/files basically IS such a PR
Yes kind of.
Actually my belief is that taskkill
should be faster for windows.
Never merged?
And IIRC he implemented taskkill and it's really performant.
I'll work on this as soon as possible, right now I'm a bit busy.