-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMacOS_sysctl.sh
More file actions
executable file
·56 lines (49 loc) · 3.22 KB
/
Copy pathMacOS_sysctl.sh
File metadata and controls
executable file
·56 lines (49 loc) · 3.22 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
#!/bin/bash
echo "From MacOS Catalina 10.15.3, /etc/sysctl.conf values are no longer respected. You need to set sysctls via plists instead (this script does this)"
echo
echo "Updating sysctl values on Ventura is generally not required anymore as Apple have already provided sane defaults to achieve 10Gbps performance"
echo "Make sure you have read the changes in 'Library_LaunchDaemons_com.startup.sysctl.plist'"
echo "In particular make sure you understand 'net.inet.tcp.tso' & 'kern.ipc.nmbclusters' and configure for your use case (info in README.md). These have the most impact."
echo
echo "NB; Installing plists into /Library/LaunchDaemons does NOT require disabling SIP."
echo "Some individual sysctl keys may still refuse to change on some configurations - check /tmp/sysctl.err after reboot, and only then investigate SIP."
read -r -p "Are you sure you want to increase sysctl values? [y/n]" iamsure
if [[ "$iamsure" != "y" ]]; then
exit
fi
# Needs further testing (requires machine with at least 32 or 64 GB RAM);
# <string>kern.sysv.shmmax=4194304</string>
# <string>kern.sysv.shmmin=1</string>
# <string>kern.sysv.shmmni=32</string>
# <string>kern.sysv.shmseg=8</string>
# <string>kern.sysv.shmall=1024</string>
# kern.maxvnodes (old macs default 66560, Ventura default 263168, serverperfmode default 300000)
# kern.maxproc (old macs default 1064, Ventura default 16000, serverperfmode default 5000)
# kern.maxfilesperproc (old macs default 10240, Ventura default 245760, serverperfmode default 150000)
# kern.maxprocperuid (old macs default 709, Ventura default 10666, serverperfmode default 3750)
# kern.ipc.maxsockbuf (old macs default 4194304, Ventura default 8388608, serverperfmode default 8388608)
# kern.ipc.somaxconn (old macs default 128, Ventura default 128, serverperfmode default 1024)
# kern.ipc.nmbclusters (old macs default 32768, Ventura default 262144, serverperfmode default 65536)
# Two profile variants ship with this repo (same Label, deploy one only);
# Library_LaunchDaemons_com.startup.sysctl.plist - current default (delayed_ack=3 auto, win_scale=8, 32MB autobufs, nmbclusters=262144)
# Library_LaunchDaemons_com.startup.sysctl_ventura.plist - earlier variant (delayed_ack=1, win_scale=6, 8MB autobufs, nmbclusters=524288)
SYSCTL_PLIST="./Library_LaunchDaemons_com.startup.sysctl.plist"
echo "Updating /Library/LaunchDaemons/com.startup.sysctl.plist (from ${SYSCTL_PLIST})"
sudo cp -f "${SYSCTL_PLIST}" /Library/LaunchDaemons/com.startup.sysctl.plist
sudo chown root:wheel /Library/LaunchDaemons/com.startup.sysctl.plist
# validate key-value pairs
plutil /Library/LaunchDaemons/com.startup.sysctl.plist
# load plist
sudo launchctl bootstrap system /Library/LaunchDaemons/com.startup.sysctl.plist
# check logs
tail /tmp/sysctl.out
tail /tmp/sysctl.err
echo "Updating /Library/LaunchDaemons/limit.maxfiles.plist"
sudo cp -f ./Library_LaunchDaemons_limit.maxfiles.plist /Library/LaunchDaemons/limit.maxfiles.plist
sudo chown root:wheel /Library/LaunchDaemons/limit.maxfiles.plist
plutil /Library/LaunchDaemons/limit.maxfiles.plist
sudo launchctl bootstrap system /Library/LaunchDaemons/limit.maxfiles.plist
echo
echo "Current System Limits"
ulimit -a
launchctl limit maxfiles