@cryptotaxi247 / kubo / commits / e575c93dc

misc: add collect-profiles.sh script, update gitignore

License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>

Jakub Sztandera committed Mar 5, 2019 at 12:57 UTC e575c93dcd4b6f6254b1a0110b26bbf1d305eb61
2 files changed +41
.gitignore
+2
@@ -17,6 +17,8 @@ gx-workspace-update.json
17 bin/gx
18 bin/gx*
19 bin/tmp
20 +bin/gocovmerge
21 +bin/cover
22
23
24 vendor
bin/collect-profiles.sh new
+39
@@ -0,0 +1,39 @@
1 +#!/usr/bin/env bash
2 +set -x
3 +set -euo pipefail
4 +IFS=$'\n\t'
5 +
6 +HTTP_API="${1:-localhost:5001}"
7 +tmpdir=$(mktemp -d)
8 +export PPROF_TMPDIR="$tmpdir"
9 +pushd "$tmpdir"
10 +
11 +echo Collecting goroutine stacks
12 +curl -o goroutines.stacks "http://$HTTP_API"'/debug/pprof/goroutine?debug=2'
13 +
14 +echo Collecting goroutine profile
15 +go tool pprof -symbolize=remote -svg -output goroutine.svg "http://$HTTP_API/debug/pprof/goroutine"
16 +
17 +echo Collecting heap profile
18 +go tool pprof -symbolize=remote -svg -output heap.svg "http://$HTTP_API/debug/pprof/heap"
19 +
20 +echo "Collecting cpu profile (~30s)"
21 +go tool pprof -symbolize=remote -svg -output cpu.svg "http://$HTTP_API/debug/pprof/profile"
22 +
23 +echo "Enabling mutex profiling"
24 +curl -X POST -v "http://$HTTP_API"'/debug/pprof-mutex/?fraction=4'
25 +
26 +echo "Waiting for mutex data to be updated (30s)"
27 +sleep 30
28 +curl -o mutex.txt "http://$HTTP_API"'/debug/pprof/mutex?debug=2'
29 +go tool pprof -symbolize=remote -svg -output mutex.svg "http://$HTTP_API/debug/pprof/mutex"
30 +echo "Disabling mutex profiling"
31 +curl -X POST -v "http://$HTTP_API"'/debug/pprof-mutex/?fraction=0'
32 +
33 +popd
34 +tar cvzf "./ipfs-profile-$(uname -n)-$(date -Iseconds).tar.gz" -C "$tmpdir" .
35 +rm -rf "$tmpdir"
36 +
37 +
38 +
39 +