The prep-script.sh
will setup the latest Node and install the latest perf version on your Linux box.
When you want to generate the flame graph, run the following (folder locations taken from install script):
sudo sysctl kernel.kptr_restrict=0
# May also have to do the following:
# (additional reading http://unix.stackexchange.com/questions/14227/do-i-need-root-admin-permissions-to-run-userspace-perf-tool-perf-events-ar )
sudo sysctl kernel.perf_event_paranoid=0
perf record -i -g -e cycles:u -- ~/sources/node/node --perf-basic-prof script.js
perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' | ~/sources/FlameGraph/stackcollapse-perf.pl > out.perf-folded
~/sources/FlameGraph/flamegraph.pl out.perf-folded > node-flame.svg
The data munging is to help expose the most important bits. There is still some play that I'm working with, but right now it seems to be working.
Alternatives:
perf script | egrep -v "( __libc_start|node::Start\(| LazyCompile | Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | ../FlameGraph/stackcollapse-perf.pl | grep "uv_run" > out.perf-folded
perf script | egrep -v "( __libc_start|node::Start\(| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | ../FlameGraph/stackcollapse-perf.pl | grep "uv_run" > out.perf-folded
I encountered the following errors:
E: Unable to locate package llvm-3.6
E: Couldn't find any package by regex 'llvm-3.6'
E: Unable to locate package clang-3.6
E: Couldn't find any package by regex 'clang-3.6'
E: Unable to locate package lldb-3.6
E: Couldn't find any package by regex 'lldb-3.6'
E: Unable to locate package libllvm3.6
E: Couldn't find any package by regex 'libllvm3.6'
It seems that llvm/clang/lldb/libllvm 3.6 packages were removed. To fix this issue, I simply switched to 3.5 packages. Hopefully this will help some people.