sindresorhus/ps-list

Improve Windows performance

Closed this issue · 4 comments

Instead of using the tasklist module which is a wrapper around the tasklist command, we could write a new native module that is faster than tasklist. As an experiment, I wrote a simple C++ tool called fastlist some time ago, which was 5x faster for listing processes than tasklist.

@sindresorhus Would you be in favor of using a native module in this case? (I have little to no experience maintaining native modules so I'm not quite sure about the implications of that.)

Native Node.js addon-ons come with a lot of pain, especially on Windows. Not sure I want to deal with that mess. But if you mean just spawning your binary, I'm totally up for that. Would be great if your binary could include memory and CPU info too (#8).

Native Node.js addon-ons come with a lot of pain, especially on Windows. Not sure I want to deal with that mess.

True, executing a binary is probably the easiest to maintain.

Would be great if your binary could include memory and CPU info too (#8).

The tasklist module already returns the memory usage, but ps-list is not passing that property along at the moment. I guess that's an easy 1 line fix. :)


I have updated fastlist a bit (CI, binary releases, benchmark). In comparison to tasklist, it does not print the session name, session number, nor the memory usage of each process, but it does additionally print the parent process ID.

In summary:

  • ps-list is supposed to return the parent process ID, the memory usage, and the CPU usage.
  • tasklist returns the memory usage, but neither the parent process ID, nor the CPU usage.
  • fastlist returns the parent process ID, but neither the memory usage, nor the CPU usage.

I believe adding memory and CPU usage to fastlist should be possible without too much hassle, but I haven't tried it yet.

Great, then I’m more than happy to switch to fastlist.

Adding memory and CPU usage is a bit trickier than expected, partially because Windows Performance Counters are, for some reason, broken on my machine. I created a preliminary PR (#21) nonetheless.