Skip to content

Instantly share code, notes, and snippets.

@nilreml
Last active March 12, 2024 10:29
Show Gist options
  • Save nilreml/c71e82319492394ad778e0d1bb3d8cb5 to your computer and use it in GitHub Desktop.
Save nilreml/c71e82319492394ad778e0d1bb3d8cb5 to your computer and use it in GitHub Desktop.
NOTE: don't do any of this unless you understand all it's implications
https://engineering.linkedin.com/performance/optimizing-linux-memory-management-low-latency-high-throughput-databases
Linux's NUMA optimizations can be effectively disabled by doing the following:
Turn zone reclaim mode off: add vm.zone_reclaim_mode = 0 to /etc/sysctl.conf and run sysctl -p to load the new settings.
Enable NUMA interleaving for your application: run with numactl --interleave=all COMMAND
These are now the defaults on all our production systems.
Filesystem benchmarking:
fio --name TEST --eta-newline=5s --filename=fio-tempfile.dat --rw=randread --size=2g --io_size=4g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --numjobs=1 --runtime=10 --group_reporting
fio --name TEST --eta-newline=5s --filename=fio-tempfile.dat --rw=randrw --size=2g --io_size=4g --blocksize=4k --ioengine=libaio --fsync=1 --iodepth=1 --numjobs=1 --runtime=10 --group_reporting
ioping -c 1000 -s 4k -S 1G -i 0 -G . >test1.txt
Minimize swapping
echo "vm.swappiness=1" | sudo tee -a /etc/sysctl.d/42-swappiness.conf
sysctl --system
disable spectre/meltdown mitigations
kernel >= 5.2: mitigations=off
intel igpu: i915.mitigations=off
disable apparmor
apparmor=0
bfq io scheduler (>4.15 kernel)
kernel commandline:
scsi_mod.use_blk_mq=1
/etc/modules-load.d/bfq.conf:
bfq
/etc/udev/rules.d/50-scheduler.rules:
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/scheduler}="bfq" [https://gist.github.com/wooptoo/835f377d88ef9fb11a21e735630d7470]
sudo udevadm control --reload
sudo udevadm trigger
check trim support:
sudo hdparm -I /dev/[...] | grep TRIM
Update grub
update-grub
Disable journaling (don't do this):
boot into single user mode
remount / as ro
sudo tune2fs -O ^has_journal $SSD_DRIVE
Avoid slow shutdown due to CUPS
sudo EDITOR=vim systemctl edit cups-browsed
[Service]
TimeoutStopSec=1
Alternatively:
sudo systemctl stop cups-browsed.service
sudo systemctl disable cups-browsed.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment