Tools and resources regarding Node.js and Performance Tools Integration
#4 opened on Jun 22, 2014
Description
goal
I'm trying to gather resources and tools that make it easier to profile Node.js apps ideally by integrating with Chrome Dev tools and chrome://tracing.
what I found so far
Documentation of tools to analyse the data has been started here but the integration part with Node.js is still missing.
I tried to gather some free and open source tools that try to make this easier and would love to get some feedback and/or further tool suggestions. Pointers to any resources that document anything related are also greatly appreciated.
tools
| Name | In app initialization | Instrumentation | Description |
|---|---|---|---|
| memwatch | Yes | No | Leak detection and heap usage and diffing. |
| heapdump | Yes | No | Make a dump of the V8 heap for later inspection |
| profiler | Yes | Resume/Pause | Access the V8 profiler from node.js DEPRECATED |
| v8-profiler | Yes | Start/Stop | Provides node bindings for the v8 profiler and integration with node-inspector |
| node-gc | Yes | Handle Events | Emits events from the V8 garbage collector to let you know when garbage collection occurs |
| gc-stats | Yes | Handle Events | Emits GC stats events after GC occurred |
| webkit-devtools-agent | Yes | No | Implementation of Chrome developer tools protocol. Only the heap and CPU profilers are working right now. |
| trace-viewer | Yes | Yes | JavaScript frontend for Chrome about:tracing and Android systrace. It provides rich analysis and visualization capabilities for trace files, supporting both the linux kernel trace format and Chrome's base/trace_event |
| tracing-framework | No | Yes | A set of libraries, tools, and visualizers for the tracing and investigation of complex web applications. It helps discover performance problems, track regressions, and build buttery-smooth 60fps web apps. |
| irhydra | No | No | Tool that can display intermediate representations used by V8 and Dart VM optimizing compilers |
| cpu-profiler | Yes | Start/Stop | Node bindings for the v8 cpu profiler |
| chrome-cpu-profiler | Yes | Start/Stop | Allows viewing top down, bottom up and callgraphs of a node app in Google Chrome |
| perf-cpuprofile | No | No | Converts linux perf tool output to .cpuprofile files readable by chromiums devtools |
webkit-devtools-agent looks very promising, but doesn't show flamegraphs and has no time line support.
techniques
With a version of node that has a --log-timer-events as part of v8-options, run the app in profiling mode and load the resulting v8.log into Chrome at chrome://tracing.
Check for supported flag:
➝ node --v8-options | grep log_timer_events
--log_timer_events (Time events including external callbacks.)
Profile app to generate v8.log including GC events.
node --prof --track_gc_object_stats --trace_gc_verbose --log_timer_events app.js
Loading into chrome://tracing will yield a flame chart similar to the below:

A detailed explanation is outlined in creating v8 profiling timeline plots although some of the information seems a bit outdated.
what I'm interested in
The idea is to find a way to use the built in Chrome tools to profile Node.js apps the same way as is currently possible for JavaScript apps running in the browser.
Interesting metrics to gather:
- CPU profile including flamecharts - what's described here but for Node.js apps
- Heap profile, snapshots and diffs - what's described here but for Node.js apps
- GC events and timeline
Additionally integration with chrome://tracing by passing flags like --log_timer_events are of interest.
Both, CLI and GUI support would be nice to have as well as real-time and historical data.