How to use xperf to examine the call stack of nodejs?

685 views Asked by At

I'm trying to learn performance tuning for Node.js applications. This first thing I want is a flamegraph. Since I work on Windows platform, I follow this manual to get the flamegraph.

However, I'm stacked at this step:

xperf -i perf.etl -o perf.csv -symbols enter image description here

I'm no good with xperf. Could someone tell me how to get pass this problem and get a flamegraph?

1

There are 1 answers

0
Bruce Dawson On

It's worth pointing out that xperf can record many different types of call stacks. You can get a call stack on every file I/O, disk I/O, context switch, registry access, etc., and you could create a flame graph of any one of these. I assume, however, that you want a flame graph of the CPU Sampled data.

You can find a slightly different technique for creating flame graphs from xperf sampled data on my blog, here:

https://randomascii.wordpress.com/2013/03/26/summarizing-xperf-cpu-usage-with-flame-graphs/

You don't say what your problem was -- what went wrong with that step -- so I'll give a few generic suggestions:

  1. Try with a very short trace -- just a few seconds -- to make the process as fast as possible when experimenting.
  2. Try loading the trace into WPA to make sure you can see the sampled data there. You may find that you don't need the flame graph, since WPA gives you ways to graphically explore the data. Loading the trace into WPA also gives you a chance to make sure the symbols load, and gives WPA a chance to convert the symbols to .symcache files, which will make the processing step run much faster.
  3. Make sure you have _NT_SYMBOL_PATH set to point to Microsoft's symbol servers and any others you might need.
  4. Consider recording the trace with wprui instead of with a batch file: https://randomascii.wordpress.com/2013/04/20/xperf-basics-recording-a-trace-the-easy-way/

You could probably improve on the flame graph generation process by not exporting all of the xperf data to text, by using the somewhat new wpaexporter, which I document here:

https://randomascii.wordpress.com/2013/11/04/exporting-arbitrary-data-from-xperf-etl-files/

However this will require reworking the scripts and may be more work than you want to put in.