-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathheaptrack.sh
More file actions
executable file
·75 lines (65 loc) · 2.08 KB
/
heaptrack.sh
File metadata and controls
executable file
·75 lines (65 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
if [ ! -f lib/lib.sh ]
then
echo "Error: lib/lib.sh not found!"
echo "make sure you are in the root of the server repo"
exit 1
fi
source lib/lib.sh
check_deps "$1"
check_warnings
check_running
install_dep heaptrack
archive_gmon
restart_side_runner
die_if_asan_on_because heaptrack
export COMMIT_HASH
if ! COMMIT_HASH="$(get_commit)"
then
err "failed to get commit hash"
exit 1
fi
logfile="$LOGS_PATH_FULL_TW/${CFG_SRV_NAME}_$(date +%F_%H-%M-%S)${CFG_LOG_EXT}"
cache_logpath "$logfile"
log_cmd='echo nologging'
if is_cfg CFG_ENABLE_LOGGING
then
log_cmd="logfile $logfile"
fi
heaptrack_logpath="logs/heaptrack_${COMMIT_HASH:-null}_$(date '+%F_%H-%M')"
# traditionally heaptrack also includes the pid with %p placeholder
# but then it becomes tricky for us to log the logpath
# because getting the pid only works at runtime
# we can not use $$ because its a wrapped launcher
# there should probably be a proper launch_cmd() helper
# that can pritty print args and handle pid and exit codes
# heaptrack_logpath="${heaptrack_logpath}.%p"
read -rd '' run_cmd <<- EOF
$CFG_ENV_RUNTIME heaptrack \
--output "$heaptrack_logpath" \
./$CFG_BIN -f autoexec.cfg "$log_cmd;#sid:$SERVER_UUID:heaptrack.sh"
EOF
log "$run_cmd"
git_patches="$(get_applied_git_patches)"
launch_commit="$(get_commit)"
bash -c "set -euo pipefail;$run_cmd"
log "build commit: $launch_commit"
if [ "$git_patches" != "" ]
then
log "applied patches: $git_patches"
fi
heaptrack_filename="$(basename "$heaptrack_logpath")"
log "created heaptrack report at $heaptrack_logpath"
log "you can inspect it using this command:"
echo ""
echo -e " ${WHITE}heaptrack_print ${heaptrack_logpath}.zst | less${RESET}"
echo ""
log "or publish it via http and download locally to inspect with heaptrack gui version:"
echo ""
echo -e " ${WHITE}cp ${heaptrack_logpath}.zst /var/www/html/tmp/${RESET}"
echo ""
log "then click here to download https://zillyhuhn.com/tmp/${heaptrack_filename}.zst"
log "after downloading clean it up using this command:"
echo ""
echo -e " ${WHITE}rm /var/www/html/tmp/${heaptrack_filename}.zst${RESET}"
echo ""