Created
February 23, 2022 17:35
-
-
Save yonixw/4aca7725633fe26b85cfea014aca611b to your computer and use it in GitHub Desktop.
nodejs xtrace dtrace trace performance heat map flame graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -z $1 ] || [ -z $2 ] | |
then | |
echo "Usage: [node file] [output svg]" | |
exit 1 | |
fi | |
# https://www.brendangregg.com/blog/2014-09-17/node-flame-graphs-on-linux.html | |
# https://nodejs.org/en/docs/guides/diagnostics-flamegraph/ | |
sudo perf record -e cycles:u -g -- node --interpreted-frames-native-stack --perf-basic-prof-only-functions "$1" | |
sudo perf script > perfs.out | |
sed -i \ | |
-e "/( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)/d" \ | |
-e 's/ LazyCompile:[*~]\?/ /' \ | |
perfs.out | |
./FlameGraph/stackcollapse-perf.pl < ./perfs.out | ./FlameGraph/flamegraph.pl > "$2" | |
echo "Done! saved to: $2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install & run perf (ubuntu) | |
sudo apt-get install linux-tools-common linux-tools-generic linux-tools-`uname -r` | |
# Make graph | |
git clone --depth 1 http://github.com/brendangregg/FlameGraph |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For ts-node... but that Flame Graph I got was very generic...
node -r ts-node/register ..... app.js