microsoft / vscode-js-profile-visualizer

A custom editor for viewing `.cpuprofile` files in VS Code
MIT License
139 stars 29 forks source link

No support for Multi-threading? Inaccurate CPU usage with threaded application. #76

Open lockHrt opened 2 years ago

lockHrt commented 2 years ago

CPU usage is shown 100% even when,

Attaching 2 screenshots showing different cases,

  1. Main nodejs app with 1 extra worker thread doing CPU intensive work. See, at OS level node is registering 20% CPU load. (which is close to fully utilizing one core of a quad core CPU)

Screenshot_2

  1. Main nodejs app with 7 extra worker threads doing CPU intensive work. At OS, level node is registering 89% CPU load.

Screenshot_3

In both cases, CPU usage is shown 100%. Secondly, the graph itself has ups and downs which is not reflected in the CPU usage number.

Also is it possible to get total RAM usage? In the second screenshot, heap is 125 MB whereas at system level, node is occupying 9.5 GBs of RAM.

connor4312 commented 2 years ago

This uses process.cpuUsage() and process.memoryUsage. memoryUsage has an option that includes worker threads, but CPU usage does not, nor does there appear to be any other way to get that from Node.

In the current design, performance shows information from the currently selected debug session. If you select the parent process, only its performance information is shown. If Node.js eventually adds cumulative APIs for CPU usage, I could see adding an option to show totals session info.