I am getting very hard time to configure Sampling Heap Profiler node module.
I would like to set up this module and want to try deploying in chrome dev tool but unfortunately, there is no document about build and deployment.
Here is the npm link - https://www.npmjs.com/package/heap-profile
Any help would be greatly appreciated.
The sampling heap profiler is designed to be used programmatically in Node.js applications.
For frontend applications, you actually don't need this module. The functionality is baked into DevTools. You can find the 'Allocation Sampling' profiler in the 'Memory' tab in Chrome Devtools:
Related
According to Node.js documentation profiling info can be generated using node --prof myapp.js.
Is there a way to convert from this generated format to Chrome's Dev Tools performance profile? It expects to load a JSON format while the format generated by node --prof is not JSON.
No, the output generated by the --prof flag is not what DevTools expects, and AFAIK there's no way to convert it.
However, there is also the --inspect flag, allowing you to use DevTools with Node, including profiling. I haven't tried it myself, but a quick search turns up e.g.:
https://medium.com/#paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27
https://developer.ibm.com/languages/node-js/tutorials/learn-nodejs-debugging-and-profiling-node-applications/#debugger-2-chrome-devtools
There are two ways for export .cpuprofile:
use cli options --cpu-prof
use inspector module. See the example usage
When using node --inspect to profile a NodeJS application using chrome dev tools, a large part of the runtime is spent in (program). I did not find information on what exactly this means? Is it just time spend in the C++ parts of NodeJS?
The (program) entry is Chrome itself - it's the first thing that gets executed before anything else and remains there regardless of what your Node application is doing.
There is discussion in this Chromium profiler issue on what exactly it means (and whether or not it's confusing).
You can also see in the comments of the Changelog for the commit also includes the following comment:
Web Inspector: [Chromium] profiler - differentiate between native code
(program) and idle time https://bugs.webkit.org/show_bug.cgi?id=88446
Reviewed by NOBODY (OOPS!).
Now idleTime is supplied in profile object. In this patch, idleTime,
if any, is subtracted from "(program)" node, and new node "(idle)" is
injected as a top level node ti profile.
My current App (WPF in Visual Studio) weighs 2MB.
And now I want to re-create this App with Node and Javascript.
Why? Primary reason is - I want to learn some Javascript (yes, this is My way to learning and please dont give me advices how to learn JS). Secondary reason - I want to use full power of CSS3, while WPF App supports only CSS2.
The problem is Weight. Any example App builded with Electron or NWJS weighs about 115MB!!!
I can understand that Desktop App require Node and Browser to work, but 115MB?!
So my question is - Is there any way to create Lightweight Desktop App with Electron/NWJS (or similar alternative)?
I can accept final weight about 50-60MB.
Electron or NW.js are huge in terms of size and required memory, but there are lightweight alternatives: Libui-node and Positron. Other lightweight platforms not based on node.js are: React-Native, XULRunner and Qt Quick with QML.
I can only speak for Electron, but 115MB sounds about right for a minimal app, the Chromium content library which Electron is based on is an all or nothing sort of thing and takes up a large chunk of that space.
Typically, I use node inspector (https://github.com/node-inspector/node-inspector) to debug node.js. Can this be used to attach to a remote node.js instance running in the JVM via J2V8?
Also, it looks like the dev version of node.js supports native Chrome debugging: https://github.com/nodejs/node/pull/6792. If J2V8 adopts this version of node.js, will I be able to simply attach the Chrome debugger directly to the JVM?
If the question is still relevant - I have created j2v8-debugger library.
It allows debugging J2V8 using Chrome DevTools.
Basic features like setting/removing breakpoints, step into, step out and step over, variables inspection, etc. are implemented.
It uses Stetho lib for communication with Chrome DevTools.
Also it's uses DebugHandler for accessing V8 debug information.
If you need need to debug J2V8, which runs on non-Android JVM you would need to use another lib for communication to Chrome DevTools, but likely you could re-use all the logic from this project as it's basically POJO/JSON, which are send over web socket.
Hope it could be helpful.
Is there any way to take a heap snapshot from a running Node.js process and then load it into the Google Chrome profiles viewer? It would be very awesome to be able to use the really useful Chrome profiles tab to view Node.js snapshots.
If it is possible to do, can someone provide a step-by-step of how to produce a snapshot in Node.js and then load it into Chrome?
There is an NPM module to do this.
https://github.com/bnoordhuis/node-heapdump
Just require() the module and then you can send kill -USR2 to the node process. It creates a V8 heap dump that you can view in Chrome.