(assuming an Ubuntu machine)
- Install perf:
sudo apt-get install linux-tools-generic
- Run
perf
and install any other listed missing package: (e.g.)sudo apt-get install linux-tools-4.4.0-1022-aws linux-cloud-tools-4.4.0-1022-aws
- Enable symbols mapping when running the Node process:
node --perf-basic-prof ...
- If the process is running within Docker, copy symbols map file from the container to the host:
- Take note of the Node process PID in the host environment. We'll call it
$PID
. - Take note of the Node process PID within the container. We'll call it
$DOCKER_PID
. sudo docker cp $CONTAINER_ID:/tmp/perf-$DOCKER_PID.map /tmp/perf-$PID.map
- Take note of the Node process PID in the host environment. We'll call it
- Profile the process for a while:
sudo perf record -F 99 -p $PID -g -v -- sleep 30
- Transform the profile data:
sudo perf script > perf.data-script
- TODO Filter out noisy entries (i.e. leave just
LazyCompile
ones) - Install FlameGraph:
git clone http://github.com/brendangregg/FlameGraph
- Build flame graph:
sudo cat perf.data-script | ./FlameGraph/stackcollapse-perf.pl | ./FlameGraph/flamegraph.pl > flamegraph.svg
- Export flame graph to a public space:
curl --upload-file flamegraph.svg https://transfer.sh/; echo
- Open the URL in any browser