node-tree-kill icon indicating copy to clipboard operation
node-tree-kill copied to clipboard

Consider using pidtree package

Open simonepri opened this issue 6 years ago • 5 comments

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

simonepri avatar Mar 20 '18 21:03 simonepri

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!

billiegoose avatar Mar 21 '18 04:03 billiegoose

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.

simonepri avatar Mar 21 '18 07:03 simonepri

Never merged?

jayarjo avatar Mar 08 '19 06:03 jayarjo

And IIRC he implemented taskkill and it's really performant.

soyuka avatar Mar 08 '19 08:03 soyuka

I'll work on this as soon as possible, right now I'm a bit busy.

simonepri avatar Mar 11 '19 08:03 simonepri