-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy path.bash_aliases
More file actions
223 lines (197 loc) · 10.1 KB
/
Copy path.bash_aliases
File metadata and controls
223 lines (197 loc) · 10.1 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
alias venv="source /opt/venv/bin/activate"
alias vpn-import="sudo openvpn3 config-import --config /home/przemek/.ssh/ovpn/profile-902.ovpn"
alias vpn-start="sudo openvpn3 session-start --config /home/przemek/.ssh/ovpn/profile-902.ovpn"
alias ssh117="ssh przemyslaw.skibinski@10.30.7.117 -i /home/przemek/.ssh/inikep-rsa4096.priv"
alias ssh134="ssh przemyslaw.skibinski@10.30.7.134 -i /home/przemek/.ssh/inikep-rsa4096.priv"
function sshini() { ssh przemyslaw.skibinski@$1 -i /home/przemek/.ssh/inikep-rsa4096.priv $2 $3; }
alias sshkvm="ssh -p 2222 -i /home/przemek/.ssh/inikep-rsa4096.priv przemek@10.30.2.13"
alias cf_on="git config --local include.path /data/mysql-server/percona-8.0/.gitconfig"
alias cf_off="git config --local --unset include.path"
alias claude-yolo="claude --dangerously-skip-permissions"
alias git-clang-format="cf_off; git clang-format $@; cf_on"
alias git-log="git log --oneline -10 $@"
alias git-logfp="git log --first-parent --topo-order --oneline -10 $@"
alias git-lg="git log --oneline $@"
alias git-lgfp="git log --first-parent --topo-order --oneline $@"
alias git-last="git log --format=%B -1"
alias git-stat="git log --stat --format='%h %s' $@"
alias git-pick="git cherry-pick"
alias git-picknc="git cherry-pick --no-commit"
alias git-amend="git cherry-pick --amend"
alias zenfs-rocks-size="zenfs list --zbd=nvme1n2 --path=./.rocksdb | awk '{sum+=\$1;} END {printf \"%d\n\", sum/1024/1024;}'"
alias zenfs-free-zones="zbd report /dev/nvme1n2 | grep em | wc -l"
alias hibernate="systemctl hibernate"
MTR_BASE="./mysql-test/mtr --debug-server --retry-failure=0 --mysqld-env=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libeatmydata.so --mysqld=--replica-parallel-workers=4"
MTR_FORCE="$MTR_BASE --force --max-test-fail=0"
MTR_SANITIZE="$MTR_FORCE --sanitize"
alias mtr-single="$MTR_BASE"
alias mtr-zenfs="sudo $MTR_BASE --mysqld=--rocksdb_fs_uri=zenfs://dev:nvme1n2"
alias mtr-jemalloc="$MTR_BASE --mysqld-env=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so:/usr/lib/x86_64-linux-gnu/libeatmydata.so"
alias mtr-valgrind="$MTR_FORCE --shutdown-timeout=150 --valgrind --valgrind-clients --valgrind-option=--num-callers=32 --valgrind-option=--show-leak-kinds=all --valgrind-option=--leak-check=full"
alias mtr-massif="$MTR_BASE --shutdown-timeout=150 --valgrind --valgrind-clients --valgrind-option=--tool=massif"
function mtr-parallel-aio() { t $MTR_FORCE --parallel=64 --mysqld=--innodb_use_native_aio=0 $@; }
function mtr-parallel() { t $MTR_FORCE --parallel=auto --mysqld=--innodb_read_io_threads=4 $@; }
function mtr-parallel32() { t $MTR_FORCE --parallel=32 --mysqld=--innodb_read_io_threads=4 $@; }
function mtr-parallel64() { t $MTR_FORCE --parallel=64 --mysqld=--innodb_read_io_threads=4 $@; }
function mtr-rec() { t $MTR_FORCE --parallel=32 --record $@; }
function mtr-rec64() { t $MTR_FORCE --parallel=64 --record $@; }
function mtr-big() { t $MTR_FORCE --big-test $@; }
alias mtr-fb56="$MTR_FORCE --mysqld=--default-storage-engine=rocksdb --mysqld=--rocksdb=1 --mysqld=--skip-innodb --mysqld=--default-tmp-storage-engine=MyISAM"
alias mtr-fb80="$MTR_FORCE --mysqld=--default-storage-engine=rocksdb --charset-for-testdb=latin1"
alias mtr-sanitize="$MTR_SANITIZE --mysqld-env=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so"
alias mtr-sanitize5="$MTR_SANITIZE --mysqld-env=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.5:/usr/lib/x86_64-linux-gnu/libeatmydata.so"
alias mtr-sanitize6="$MTR_SANITIZE --mysqld-env=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.6:/usr/lib/x86_64-linux-gnu/libeatmydata.so"
alias mtr-sanitize8="$MTR_SANITIZE --mysqld-env=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8:/usr/lib/x86_64-linux-gnu/libeatmydata.so"
function t() {
export PARAMS="$@"
echo $PARAMS
/usr/bin/time --quiet -f "%e" -o ~/time.log $PARAMS
CMD_TIME=$(cat ~/time.log)
TIME_ROOT=${TIME_ROOT:-/data}
echo $CMD_TIME $@ | tee -a $TIME_ROOT/cmd_time.log
}
function get-gca() {
if [ $# -lt 2 ]; then
echo "usage: $0 <lower_branch> <higher_branch>"
else
gca_rev="$(git rev-list "$1" ^"$2" --first-parent --topo-order | tail -1)^"
gca_num="$(git rev-list "$1" ^"$2" --first-parent --topo-order | wc -l)"
echo "The number of commits from '$1' missing in '$2' = $gca_num"
echo "GCA of '$1' and '$2' = $gca_rev"
git log --oneline -1 $gca_rev
fi
}
function mtr-result-files() {
if [ $# -lt 1 ]; then
echo "usage: $0 [commit1] <commit2>"
else
if [ "$2" = "" ]; then PREV=$1~; else PREV=$2; fi
echo "commits $PREV..$1"
printf "mtr-rec " && git diff $PREV..$1 --name-only | grep -Po "[[:alnum:]_-]*(?=(\.result|\.test|-master\.opt))" | sort | uniq | tr '\n' ' '; echo;
fi
}
# INST_LIST="c5.4xlarge c6i.8xlarge" REGION=us-west-2 aws-prices
function aws-prices() {
for inst in ${INST_LIST};
do
echo $inst;
sudo docker run --rm ghcr.io/alexei-led/spotinfo --type="$inst" --region="${REGION}" --os=linux --output=text --sort=interruption;
aws ec2 --region="${REGION}" describe-spot-price-history --instance-types "$inst" --product-description "Linux/UNIX (Amazon VPC)" --start-time $(date +%s) --query SpotPriceHistory[].[InstanceType,AvailabilityZone,SpotPrice] --output text;
done
}
function drop-caches() {
sync
sudo sh -c 'sysctl -q -w vm.drop_caches=3'
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
}
function count-lines() { cat $1 | rev | cut -f 1,2 -d '.' | rev | sort | uniq -c | sort -nr > $1_sorted; }
function git-worktree() { git worktree add -b $1 ../$1 $2 $3 $4; cd ../$1; }
function git-mergetool() { git checkout --conflict=merge $1; git mergetool $1; }
function git-commitfile() { git add $1; git commit -m"$1"; }
function git-diff-files() { git diff $1~..$1 $2 $3 $4; }
function git-squash() {
if [ $# -lt 1 ]; then
echo usage: $0 [num_of_commits]
else
git reset --soft HEAD~$1 && git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
git commit
fi
}
function git-split() {
if [ $# -lt 1 ]; then
echo usage: $0 [file_names]
else
git reset HEAD^ -- $@
git commit --amend
git add $@
git commit --reuse-message=HEAD@{1}
git commit --amend
fi
}
function git-unmerge() {
if [ $# -lt 2 ]; then
echo usage: $0 [start_commit] [end_commit]
else
git log --pretty='%H' --topo-order $1..$2 --reverse | xargs git cherry-pick -m1
fi
}
function git-unmerge-plan() {
if [ $# -lt 2 ]; then
echo usage: $0 [start_commit] [end_commit]
else
git log --oneline --topo-order $1..$2 --reverse
fi
}
function fb-worktree() { git fetch facebook && cd ../fb-8.0.13 && git checkout fb-8.0.13 && git pull && git worktree add -b $@ ../$@ facebook/fb-mysql-8.0.13; cd ../$@; }
function fb-update() { MYPWD=`pwd`; git fetch facebook && cd ../fb-8.0.13 && git checkout fb-8.0.13 && git pull; cd $MYPWD; }
function disable_address_randomization(){
PREVIOUS_ASLR=`cat /proc/sys/kernel/randomize_va_space`
sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"
echo "Changing /proc/sys/kernel/randomize_va_space from $PREVIOUS_ASLR to `cat /proc/sys/kernel/randomize_va_space`"
}
function restore_address_randomization(){
local CURRENT_ASLR=`cat /proc/sys/kernel/randomize_va_space`
sudo sh -c "echo $PREVIOUS_ASLR > /proc/sys/kernel/randomize_va_space"
echo "Resoring /proc/sys/kernel/randomize_va_space from $CURRENT_ASLR to `cat /proc/sys/kernel/randomize_va_space`"
}
function disable_turbo_boost(){
SCALING_DRIVER=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_driver`
echo "Using $SCALING_DRIVER scaling driver"
if [[ ${SCALING_DRIVER} == "intel_pstate" || ${SCALING_DRIVER} == "intel_cpufreq" ]]; then
PREVIOUS_TURBO=`cat /sys/devices/system/cpu/intel_pstate/no_turbo`
sudo sh -c "echo 1 > /sys/devices/system/cpu/intel_pstate/no_turbo"
echo "Changing /sys/devices/system/cpu/intel_pstate/no_turbo from $PREVIOUS_TURBO to `cat /sys/devices/system/cpu/intel_pstate/no_turbo`"
else
PREVIOUS_TURBO=`cat /sys/devices/system/cpu/cpufreq/boost`
sudo sh -c "echo 0 > /sys/devices/system/cpu/cpufreq/boost"
echo "Changing /sys/devices/system/cpu/cpufreq/boost from $PREVIOUS_TURBO to `cat /sys/devices/system/cpu/cpufreq/boost`"
fi
}
function restore_turbo_boost(){
echo "Restore turbo boost with $SCALING_DRIVER scaling driver"
if [[ ${SCALING_DRIVER} == "intel_pstate" || ${SCALING_DRIVER} == "intel_cpufreq" ]]; then
CURRENT_TURBO=`cat /sys/devices/system/cpu/intel_pstate/no_turbo`
sudo sh -c "echo $PREVIOUS_TURBO > /sys/devices/system/cpu/intel_pstate/no_turbo"
echo "Resoring /sys/devices/system/cpu/intel_pstate/no_turbo from $CURRENT_TURBO to $PREVIOUS_TURBO"
else
CURRENT_TURBO=`cat /sys/devices/system/cpu/cpufreq/boost`
sudo sh -c "echo $PREVIOUS_TURBO > /sys/devices/system/cpu/cpufreq/boost"
echo "Resoring /sys/devices/system/cpu/cpufreq/boost from $CURRENT_TURBO to $PREVIOUS_TURBO"
fi
}
function change_scaling_governor(){
PREVIOUS_GOVERNOR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
sudo cpupower frequency-set -g $1
echo "Changing scaling governor from $PREVIOUS_GOVERNOR to `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`"
sudo cpupower frequency-info
}
function restore_scaling_governor(){
local CURRENT_GOVERNOR=`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`
sudo cpupower frequency-set -g $PREVIOUS_GOVERNOR
echo "Restoring scaling governor from $CURRENT_GOVERNOR to `cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`"
sudo cpupower frequency-info
}
function set_performance(){
disable_address_randomization
disable_turbo_boost
change_scaling_governor performance
}
function restore_from_performance(){
restore_address_randomization
restore_turbo_boost
restore_scaling_governor
}
function check_errors() {
local target_dir="$1"
# save the current directory
local orig_dir="$PWD"
# go to target directory
cd "$target_dir" || { echo "Cannot cd into $target_dir"; return 1; }
# loop through subdirectories
for dir in $(ls -d */ | sort -V); do
echo "${dir%/}"
grep -iE "sanit|terribly wrong|ERROR|seqno|Assertion|loose" "$dir/log/master.err"
done
# return to original directory
cd "$orig_dir" || { echo "Cannot return to $orig_dir"; return 1; }
}