-
Notifications
You must be signed in to change notification settings - Fork 152
/
run
executable file
·52 lines (41 loc) · 2.91 KB
/
run
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
#!/bin/bash
# objdump target/release/deps/napkin_math-fa556eccfee5460a --disassemble=memory_read_sequential_single_thread
# RUSTFLAGS='-C target-cpu=native' cargo build --release
# RUSTFLAGS='-C target-cpu=native' cargo run --release -- $@
# RUSTFLAGS='-C target-cpu=native' cargo bench -- $@
# RUSTFLAGS='-C target-cpu=native' cargo bench -- $@
# https://easyperf.net/blog/2019/08/02/Perf-measurement-environment-on-Linux#1-disable-turboboost
echo 1 | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo
# AMD
# echo 0 > /sys/devices/system/cpu/cpufreq/boost
for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
do
echo "performance" | sudo tee "${i}"
done
echo 3 | sudo tee /proc/sys/vm/drop_caches
sync
echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
sudo script/toggle-hyperthreading -d > /dev/null
echo 'always' | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
echo 'always' | sudo tee /sys/kernel/mm/transparent_hugepage/defrag
RUSTFLAGS="-C target-cpu=native" perf stat \
-- cargo bench "${@}"
# RUSTFLAGS="-C target-feature=+avx,+avx2,+sse2,+sse3" perf stat \
# -- nice -n -5 cargo bench "${@}"
# perf stat --detailed --detailed --detailed \
# -- nice -n -5 cargo bench
# RUSTFLAGS='-C target-cpu=native' cargo run --release -- $@
echo 'madvise' | sudo tee /sys/kernel/mm/transparent_hugepage/enabled
echo 'madvise' | sudo tee /sys/kernel/mm/transparent_hugepage/defrag
sudo script/toggle-hyperthreading -e # always re-enable after
# RUSTFLAGS="-C target-cpu=native" nice -n -5 cargo bench
# This binary will show when doing `cargo bench`!
# http://www.codeofview.com/fix-rs/2017/01/24/how-to-optimize-rust-programs-on-linux/
# valgrind --tool=callgrind --dump-instr=yes \
# --simulate-cache=yes \
# -- target/release/deps/memory_read-0f307ff37948551e --test
# gcloud compute instances create instance-1 --project=omphalos-1186 --zone=us-central1-c --machine-type=n2-standard-16 --network-interface=network-tier=PREMIUM,subnet=default --maintenance-policy=MIGRATE --provisioning-model=STANDARD --service-account=438246618084-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --min-cpu-platform=Intel\ Ice\ Lake --create-disk=auto-delete=yes,boot=yes,device-name=instance-1,image=projects/debian-cloud/global/images/debian-10-buster-v20220118,mode=rw,size=10,type=projects/omphalos-1186/zones/us-east4-b/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --reservation-affinity=any
# apt-get update
# apt-get install git build-essential pkg-config libssl-dev
# git clone https://github.com/sirupsen/napkin-math
# curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh