forked from AI-Hypercomputer/maxtext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rto_setup.sh
61 lines (48 loc) · 1.64 KB
/
rto_setup.sh
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
echo "Running rto_setup.sh"
# Stop execution if any command exits with error
set -e
echo "Adjust Network settings and apply non cache copy"
# Install ip.
apt-get update
yes | apt-get install net-tools
yes | apt-get install iproute2
yes | apt-get install procps
yes | apt-get install ethtool
# Disable slow start after idle
sysctl net.ipv4.tcp_slow_start_after_idle=0
# Disable metrics cache
sysctl net.ipv4.tcp_no_metrics_save=1
# Address rto_min issue with two default routing entries: screen/7RGgkiXkGXSeYF2
route=$(ip route show | sed -n 1p)
second_route=$(ip route show | sed -n 2p)
if [[ "${second_route}" =~ ^default.* ]]; then
modified_route=${route//" lock"/}
ip route delete ${modified_route}
fi
route=$(ip route show | sed -n 1p)
echo "route rto before change: $route"
if [[ "${route}" =~ .*lock.*5ms.* ]]; then
echo "${route}"
else
# shellcheck disable=SC2086
ip route change $route rto_min 5ms
fi
route=$(ip route show | sed -n 1p)
echo "route rto after change: $route"
# Disable Cubic Hystart Ack-Train
echo 2 > /sys/module/tcp_cubic/parameters/hystart_detect
# Improve handling SYN burst
echo 4096 > /proc/sys/net/core/somaxconn
echo 4096 > /proc/sys/net/ipv4/tcp_max_syn_backlog
# Disable MTU Discovery
echo 0 > /proc/sys/net/ipv4/tcp_mtu_probing
# Increase TCP Zerocopy control memory
sysctl -w net.core.optmem_max=131072
# Printing output of `ip route show`
echo -e "\nPrinting output of 'ip route show':"
ip route show
first_line_res=$(ip route show | head -n 1)
dev_name=$(echo "$first_line_res" | awk -F'[[:space:]]' '{ print $5 }')
echo "dev_name=${dev_name}"
ethtool -K "${dev_name}" tx-nocache-copy on
echo "rto_setup.sh finished"