1#!/bin/bash
2
3# Notes for fixing this script if it's broken:
4# - if you see an error about "can't find perf_6.1" you need to install `linux-perf` from the
5# version of Debian that matches the host (e.g. apt-get -t bookworm-backports install linux-perf)
6# - if you see an error about `addr2line` you may need to install binutils
7
8set -euo pipefail
9
10source script/lib/deploy-helpers.sh
11
12if [[ $# != 1 ]]; then
13 echo "Usage: $0 <production|staging>"
14 exit 1
15fi
16environment=$1
17
18target_zed_kube_cluster
19
20echo "Running perf on collab, collecting 30s of data..."
21
22kubectl -n $environment exec -it deployments/collab -- perf record -p 1 -g -m 64 --call-graph dwarf -- sleep 30
23
24run="collab-$environment-$(date -Iseconds)"
25echo "Processing data and downloading to '$run.perf'..."
26
27kubectl -n $environment exec -it deployments/collab -- perf --no-pager script > "$run.perf"
28
29which inferno-flamegraph 2>/dev/null || (echo "installing inferno..."; cargo install inferno)
30
31inferno-collapse-perf "$run.perf" | inferno-flamegraph > "$run.svg"
32open "$run.svg"