xcodenode.jsperformanceflamegraph

Node.js performance's analysis through flame graph (on Mac)


Flame graphs are a visualization of profiled software, allowing the most frequent code-paths to be identified quickly and accurately — Brendan Gregg on flame graph

Using node --perf-basic-prof with Xcode Instruments (on Mac) should help to generate a flame graph for performance analysis. Following this guide, it's rather easy:

  1. made node.js 0.12 generate a perf-<pid>.map using node --perf-basic-prof app.js
  2. record a stack using Xcode instruments time profiler (exported as profile.csv)
  3. generate a flame graph with Brendan Gregg perl tools, using ./stackcollapse-instruments.pl profile.csv | ./flamegraph.pl > graph.svg

Sadly, the generated flame graph does not benefit from the perf-<pid>.map thus leaving method adresses instead of their name (1cfc9a09b880 instead of LazyCompile:~ /node_modules/benchmark/benchmark.js:1870).

Is there any way to give the mappings / symbols to Xcode instruments, to made it generate a csv file with method names (this doesn't work)?


Solution

  • This can be done through the ui of the node flamegraph module.

    ps. a pull request offers to add the option to the npm command line tool to allow typing flamegraph -t instruments -f profile.csv -m perf-4499.map -o flamegraph.svg