Updated 6th of July 2026 (fixed typo "network-turning" - facepalms).
Note: This page is subject to change.
When applying something, please don't just copypasta it. Please read and check the docs.
Note: Remember to make sh scripts executable (+x), otherwise your system won't be able to execute them.
Note: Remember to enable services, otherwise they won't start.
Note: Once again remember to not blindly copypasta the content of this page, tweak accordingly.
This synopsis contains the main modifications I have applied to my Arch Linux system in specific.
The Arch Linux Wiki provides updated and useful information on how to maintain your Arch Linux installation and how to optimize the installation.
/etc/sysctl.d/99-network-tuning.conf
# Maximize the read/write socket buffer size (64MB)
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
# Maximum memory allocated for TCP buffers (min, default, max in bytes)
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
# Increase number of incoming packets queued before the kernel drops them
net.core.netdev_max_backlog = 10000
# Increase maximum number of open sockets waiting for connection
net.core.somaxconn = 4096
# Enable TCP Fast Open (caches cryptographic cookies to speed up subsequent connections)
net.ipv4.tcp_fastopen = 3
# Optimizations for high-bandwidth, low-latency (BBR congestion control)
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr
/etc/sysctl.d/fs_caching.conf
vm.dirty_ratio = 80
vm.dirty_background_ratio = 40
vm.dirty_expire_centisecs = 60000
vm.dirty_writeback_centisecs = 5000
vm.vfs_cache_pressure = 10
/etc/udev/rules.d/99-readahead.rules
SUBSYSTEM=="block", KERNEL=="sd*", ACTION=="add", RUN+="/sbin/blockdev --setra 8192 /dev/%k"
SUBSYSTEM=="block", KERNEL=="nvme*", ACTION=="add", RUN+="/sbin/blockdev --setra 8192 /dev/%k"
/etc/sysctl.d/split_lock.conf
kernel.split_lock_mitigate = 0
/etc/modules-load.d/bbr.conf
tcp_bbr
/etc/modules-load.d/ifb.conf
ifb
/etc/tmpfiles.d/thp.conf
w /sys/kernel/mm/transparent_hugepage/enabled - - - - always
w /sys/kernel/mm/transparent_hugepage/defrag - - - - defer+madvise
preempt=full threadirqs mitigations=off split_lock_detect=off intel_pstate=active nvidia.NVreg_EnableGpuFirmware=1 nowatchdog nmi_watchdog=0 audit=0 rcu_nocbs=1-3 nohz_full=1-3 isolcpus=managed_irq,1-3
/etc/systemd/system/usb-irq-pinning.service
[Unit]
Description=Pin USB XHCI Interrupts to Dedicated CPU Core
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/pin-xhci.sh
[Install]
WantedBy=multi-user.target
/usr/local/bin/pin-xhci.sh
#!/bin/bash
TARGET_CORE="3"
HEX_MASK=$(printf "%x" $((1 << TARGET_CORE)))
for irq in $(grep xhci /proc/interrupts | awk -F: '{print $1}' | tr -d ' '); do
echo "Pinning IRQ $irq to core $TARGET_CORE with mask $HEX_MASK"
echo "$HEX_MASK" > /proc/irq/$irq/smp_affinity
done
Note: You might need to tune or disable the irqbalance service as well.
/etc/systemd/system/sync-on-shutdown.service
[Unit]
Description=Flush filesystem buffers before shutting down
After=multi-user.target
[Service]
Type=oneshot
RemainAfterExit=true
ExecStart=/bin/true
ExecStop=/usr/bin/sync
[Install]
WantedBy=multi-user.target
/usr/lib/systemd/system-shutdown/force-sync.sh
#!/bin/sh
/usr/bin/sync
/etc/systemd/system/net-shaper.service
[Unit]
Description=Bufferbloat Shaper
After=network.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/net-shaper.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
/usr/local/bin/net-shaper.sh
#!/bin/bash
# Clear existing rules
tc qdisc del dev enp4s0 root 2>/dev/null
tc qdisc del dev enp4s0 ingress 2>/dev/null
tc qdisc del dev ifb0 root 2>/dev/null
# Load IFB
# modprobe ifb numifbs=1
ip link add name ifb0 type ifb
ip link set dev ifb0 up
# Upload Shaping
tc qdisc add dev enp4s0 root cake bandwidth 445mbit ack-filter ethernet
# Download Shaping
tc qdisc add dev enp4s0 handle ffff: ingress
tc filter add dev enp4s0 parent ffff: protocol all u32 match u32 0 0 action mirred egress redirect dev ifb0
tc qdisc add dev ifb0 root cake bandwidth 2050mbit ethernet
/etc/systemd/system/nvidia-cache-ram.service
[Unit]
Description=Redirect NVIDIA Shader Cache to RAM
After=tmp.mount home.mount
Requires=tmp.mount
Before=display-manager.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/nvidia-ram-cache.sh start
ExecStop=/usr/local/bin/nvidia-ram-cache.sh stop
[Install]
WantedBy=multi-user.target
/usr/local/bin/nvidia-ram-cache.sh
#!/bin/bash
USER_CACHE="/home/melody/.cache/nvidia"
BACKUP_CACHE="/home/melody/.cache/nvidia.bak"
RAM_CACHE="/tmp/nvidiashaders"
USER_NAME="melody"
case "$1" in
start)
# 1. Clear stale symlink if previous shutdown was unclean
if [ -L "$USER_CACHE" ]; then
rm "$USER_CACHE"
fi
# 2. Process existing physical directory
if [ -d "$USER_CACHE" ] && [ ! -L "$USER_CACHE" ]; then
# Create a fresh backup copy on disk
rm -rf "$BACKUP_CACHE"
cp -a "$USER_CACHE" "$BACKUP_CACHE"
# Prepare RAM directory and populate it
mkdir -p "$RAM_CACHE"
cp -a "$USER_CACHE"/. "$RAM_CACHE/" 2>/dev/null || true
rm -rf "$USER_CACHE"
else
# Ensure RAM directory exists even if no disk cache was present
mkdir -p "$RAM_CACHE"
fi
# 3. Secure permissions and create the symlink
chown -R "$USER_NAME":"$USER_NAME" "$RAM_CACHE"
ln -s "$RAM_CACHE" "$USER_CACHE"
chown -h "$USER_NAME":"$USER_NAME" "$USER_CACHE"
;;
stop)
# 1. Break the symlink connection
if [ -L "$USER_CACHE" ]; then
rm "$USER_CACHE"
fi
# 2. Recreate physical directory on disk
mkdir -p "$USER_CACHE"
# 3. Sync RAM cache back to persistent disk storage
if [ -d "$RAM_CACHE" ]; then
cp -a "$RAM_CACHE"/. "$USER_CACHE/" 2>/dev/null || true
fi
# 4. Restore proper ownership to the user
chown -R "$USER_NAME":"$USER_NAME" "$USER_CACHE"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
/etc/systemd/system/mesa-cache-ram.service
[Unit]
Description=Redirect MESA Shader Cache to RAM
After=tmp.mount home.mount
Requires=tmp.mount
Before=display-manager.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/mesa-ram-cache.sh start
ExecStop=/usr/local/bin/mesa-ram-cache.sh stop
[Install]
WantedBy=multi-user.target
/usr/local/bin/mesa-ram-cache.sh
#!/bin/bash
USER_CACHE="/home/melody/.cache/mesa_shader_cache"
BACKUP_CACHE="/home/melody/.cache/mesa_shader_cache.bak"
RAM_CACHE="/tmp/mesashaders"
USER_NAME="melody"
case "$1" in
start)
# 1. Clear stale symlink if previous shutdown was unclean
if [ -L "$USER_CACHE" ]; then
rm "$USER_CACHE"
fi
# 2. Process existing physical directory
if [ -d "$USER_CACHE" ] && [ ! -L "$USER_CACHE" ]; then
# Create a fresh backup copy on disk
rm -rf "$BACKUP_CACHE"
cp -a "$USER_CACHE" "$BACKUP_CACHE"
# Prepare RAM directory and populate it
mkdir -p "$RAM_CACHE"
cp -a "$USER_CACHE"/. "$RAM_CACHE/" 2>/dev/null || true
rm -rf "$USER_CACHE"
else
# Ensure RAM directory exists even if no disk cache was present
mkdir -p "$RAM_CACHE"
fi
# 3. Secure permissions and create the symlink
chown -R "$USER_NAME":"$USER_NAME" "$RAM_CACHE"
ln -s "$RAM_CACHE" "$USER_CACHE"
chown -h "$USER_NAME":"$USER_NAME" "$USER_CACHE"
;;
stop)
# 1. Break the symlink connection
if [ -L "$USER_CACHE" ]; then
rm "$USER_CACHE"
fi
# 2. Recreate physical directory on disk
mkdir -p "$USER_CACHE"
# 3. Sync RAM cache back to persistent disk storage
if [ -d "$RAM_CACHE" ]; then
cp -a "$RAM_CACHE"/. "$USER_CACHE/" 2>/dev/null || true
fi
# 4. Restore proper ownership to the user
chown -R "$USER_NAME":"$USER_NAME" "$USER_CACHE"
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
/etc/systemd/system/nvidia-power-limit.service
[Unit]
Description=Set NVIDIA GPU Power and Temp Limits
After=nvidia-persistenced.service
[Service]
Type=oneshot
ExecStart=/usr/bin/nvidia-smi -gtt 80
[Install]
WantedBy=multi-user.target
Note: requires intel-undervolt.
Note: requires CFG lock to be DISABLED in BIOS.
/etc/intel-undervolt.conf
enable yes
power package 253/128 253
tjoffset -20
interval 5000
daemon power
daemon tjoffset
Note: requires the realtime group to be installed plus Steam and Proton to be fully installed.
sudo usermod -a -G games username
sudo usermod -a -G realtime username
/etc/security/limits.d/99-realtime-privileges.conf
@realtime - rtprio 99
@realtime - memlock unlimited
@realtime - nice -20
For EXT4:
defaults,noatime,commit=600,data=writeback 0 2
Note: To fully apply on EXT4, the partition needs to be tweaked while unmounted. Run:
tune2fs -o journal_data_writeback /dev/actual/path/to/partition
For NTFS:
defaults,force,uid=1000,gid=1000,noatime,async,prealloc,nofail,x-systemd.mount-timeout=10 0 0
/etc/security/limits.conf
melody soft memlock unlimited
melody hard memlock unlimited
$HOME/.config/pipewire/pipewire.conf.d/10-realtime.conf
context.modules = [
{ name = libpipewire-module-rt
args = {
nice.level = -20
rt.prio = 88
rlimits.enabled = true
rtkit.enabled = false
}
flags = [ ifexists nofail ]
}
]
/etc/systemd/system/dynamic-swap.service
[Unit]
Description=Dynamic Loop Swapfile Manager
After=local-fs.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/manage-swap.sh start
ExecStop=/usr/local/bin/manage-swap.sh stop
[Install]
WantedBy=multi-user.target
/usr/local/bin/manage-swap.sh
#!/bin/bash
SWAP_FILE="/swapfile" # Change this path if you want it saved elsewhere
case "$1" in
start)
# 1. Create the 16GB file
truncate --size=16G "$SWAP_FILE"
chmod 600 "$SWAP_FILE" # Security best practice: restrict read permissions
# 2. Set up loop device and grab its dynamically assigned name
LOOP_DEV=$(losetup --show -f "$SWAP_FILE")
# 3. Format and activate
mkswap "$LOOP_DEV"
swapon "$LOOP_DEV"
;;
stop)
# 1. Find which loop device is currently tied to our swapfile
LOOP_DEV=$(losetup -j "$SWAP_FILE" | cut -d: -f1)
# 2. Deactivate and detach if it exists
if [ -n "$LOOP_DEV" ]; then
swapoff "$LOOP_DEV"
losetup -d "$LOOP_DEV"
fi
# 3. Clean up the file
rm -f "$SWAP_FILE"
;;
esac
Tip: always run sudo sync before shutting down.
/etc/systemd/system.conf
DefaultTimeoutStopSec=10s
DefaultTimeoutAbortSec=10s
DefaultDeviceTimeoutSec=10s
/etc/systemd/user.conf
DefaultTimeoutStopSec=10s
/etc/systemd/logind.conf
KillUserProcesses=yes
Note: KillUserProcesses attempts a SIGTERM first, it does not immediately execute your processes with a SIGKILL.
/etc/udev/rules.d/99-disable-pci.rules
# Disable Intel Device 8086:7a62
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0x7a62", RUN+="/bin/sh -c 'echo 1 > /sys%p/remove'"
# Disable NVIDIA Device 10de:22bc
ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{device}=="0x22bc", RUN+="/bin/sh -c 'echo 1 > /sys%p/remove'"
Tip: use sudo lspci -nn to get a human-readable output of the IDs that you need.
Note: Replace maxFrameRate with monitor refresh rate minus 3.
dxgi.maxFrameRate=237
d3d9.maxFrameRate=237
d3d11.samplerAnisotropy = 16
d3d9.samplerAnisotropy = 16
dxgi.maxFrameLatency = 1
d3d9.maxFrameLatency = 1
dxgi.syncInterval = 0
d3d9.presentInterval = 0
dxvk.latencySleep = True
Another important note: Unity games have trouble with enforced anisotropic filtering (red lines bug). Disable AF for Unity games if needed.
Note: As already mentioned previously, replace framerate ones with your monitor refresh rate minus 3.
__GL_MaxFramesAllowed=1
__GL_SYNC_TO_VBLANK=0
vblank_mode=0
VKD3D_FRAME_RATE=237
VKD3D_SWAPCHAIN_PRESENT_MODE=IMMEDIATE
MESA_VK_WSI_PRESENT_MODE=immediate
MANGOHUD_CONFIG="no_display,fps_limit=237,af=16,vsync=1,gl_vsync=0"
__GL_LOG_MAX_ANISO=4
Once again, Unity games have trouble with enforced AF. If you're running an Unity game, disable AF.
You can use things like WOW64 and other environment variables to improve your experience, such as loading Vulkan layers in a specific order, forcing Wayland in Proton, LD_PRELOADing things and so forth. If you're not preloading anything, please always use LD_PRELOAD="" to avoid the input timebomb issue. You can use Proton Experimental bleeding edge to get constant updates from the git Proton, it's usually much better than regular Proton and provides better performance. Right click on Proton Experimental in Steam, select Beta and select bleeding edge. You can force a game to use this compatibility tool from game's properties, or globally from Steam's settings. If your games are on a NTFS partition, you need to erase its compatdata folder and replace it with a symlink that points to /home/username/.local/share/Steam/steamapps/compatdata. In turn, this compatdata folder can actually be moved anywhere else as long as it's an ext4 filesystem or a fully Linux-supported filesystem, and then just symlink it back, just make sure the right permissions are in place and so forth.
You should always use power-profiles-daemon to control Intel's performance (set to performance when gaming, set to balanced when not gaming). Use nvidia-settings with its PowerMizer setting to do the same with your NVIDIA GPU. This avoid stutters and performance drops.
You can use dmemcg to efficiently use your VRAM, specifically get the dmemcg-booster, kcgroups-dmemcg and plasma-foreground-booster-dmemcg for KDE Plasma, this is the correct way to enable them:
sudo systemctl enable dmemcg-booster-system
systemctl --user enable plasma-foreground-booster
The system needs to be rebooted afterwards. Obviously, this is tested on KDE Plasma. For more details on this, look in documentation.
Use the following environment variable:
GLIBC_TUNABLES=glibc.malloc.hugetlb=2
Note: Do NOT set this system-wide, a lot of applications will break.
If you have question or wish to contribute to this page, such as correcting something or providing better information, feel free to join our Discord server by using the link below: