From c509c612e186ab7da64ac629c941b8de01ce5dd2 Mon Sep 17 00:00:00 2001 From: Ben Visness Date: Sun, 2 Jul 2023 07:09:39 -0500 Subject: [PATCH] Add dtrace + spall script --- samples/pong/.gitignore | 3 +++ samples/pong/trace.sh | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 samples/pong/.gitignore create mode 100755 samples/pong/trace.sh diff --git a/samples/pong/.gitignore b/samples/pong/.gitignore new file mode 100644 index 0000000..def138d --- /dev/null +++ b/samples/pong/.gitignore @@ -0,0 +1,3 @@ +profile.dtrace +profile.spall + diff --git a/samples/pong/trace.sh b/samples/pong/trace.sh new file mode 100755 index 0000000..48186aa --- /dev/null +++ b/samples/pong/trace.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# You will need dtrace2spall installed: +# +# go install github.com/bvisness/dtrace2spall@latest +# +# You will also need `$(go env GOPATH)/bin` on your PATH. + +# Run DTrace and save to profile.dtrace +sudo dtrace -n 'profile-997 /pid == $target/ { @[timestamp, pid, tid, ustack(100)] = count(); }' \ + -x ustackframes=100 \ + -o profile.dtrace \ + -x aggsortkey -x aggsortkeypos=0 \ + -c ./Pong.app/Contents/MacOS/orca +# Convert to Spall and save to profile.spall +cat profile.dtrace | dtrace2spall --freq 997 -o profile.spall --fields=_,pid,tid