Skip to content

Instantly share code, notes, and snippets.

@meaku
Last active December 7, 2022 01:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meaku/ad1e76df00d8ad8daa5c to your computer and use it in GitHub Desktop.
Save meaku/ad1e76df00d8ad8daa5c to your computer and use it in GitHub Desktop.
iojs / node.js flamegraphs using perf

Prerequisites

Record perf data

perf record -i -g -e cycles:u -- node --perf-basic-prof app.js

  • generate some load!

Filter

perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' > intermediate.out

or collapsable using the Flamegraph toolkit perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' | ~/tools/FlameGraph/stackcollapse-perf.pl > intermediate.out

Graph!

  • HTML (D3) stackvis < intermediate.out > flamegraph.htm
  • SVG stackvis < intermediate.out > flamegraph.png

or

  • FlameGraph SVG ~/tools/FlameGraph/flamegraph.pl intermediate.out > node-flame.svg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment