Skip to content

Profiling

Marten Seemann edited this page Jan 9, 2017 · 2 revisions

Creating flame graphs

On OS X:

go build example/main.go && ./main -www ~/Downloads
# Start a download
sudo dtrace -x ustackframes=1000 -n 'profile-99 /execname == "main" && arg1/ { @[ustack()] = count(); } tick-60s { exit(0); }' -o out.dtrace
# Ctrl+C after some time
~/src/FlameGraph/stackcollapse.pl out.dtrace > folded.dtrace && sed 's|github.com/lucas-clemente/quic-go.||g' folded.dtrace > stripped.dtrace && ~/src/FlameGraph/flamegraph.pl --minwidth 1 stripped.dtrace > dtrace.svg && open dtrace.svg

Creating detailed profiles

There are two ways. For running tests, run

go test -trace trace.out

For running the server, start the server and then download http://localhost:6060/debug/pprof/trace?seconds=30 and save it to trace.out.

Then run

go tool trace trace.out