Skip to main content

Performance Optimizations

Performance Optimizations

This page documents the specific kernel and hardware tweaks applied to Terra (Ryzen 5950X / Ubuntu 24.04) to optimize for container performance, storage throughput, and power efficiency.

⚡ CPU & Power Management

AMD P-State (Active Mode)

  • Driver: amd_pstate=active (EPP - Energy Performance Preference)
  • Benefit: Allows the kernel to communicate directly with the Zen 3 power management controller. Enables a wider frequency range (550MHz - 5000MHz) and more granular boost control.
  • Configuration: Added to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.

IRQ Balancing

  • Service: irqbalance (Installed/Enabled)
  • Benefit: Distributes hardware interrupts (HBA, NVMe, NIC) across all 32 threads. Prevents Core 0 from becoming a bottleneck during high I/O tasks.

🧠 Memory Tuning

Static Hugepages

  • Setting: hugepages=2048 (Reserving 4GB total as 2MB pages)
  • Benefit: Reduces TLB (Translation Lookaside Buffer) misses for memory-heavy apps like Minecraft (Java) and Postgres/AI services.
  • Configuration: Added to GRUB_CMDLINE_LINUX_DEFAULT in /etc/default/grub.

Kernel Memory Guard

  • Setting: init_on_alloc=0
  • Benefit: Disables the sanitization (zeroing) of memory pages at allocation time, reducing CPU overhead for high-frequency memory operations.

💾 I/O & Network Tuning (sysctl)

ZFS Write Buffering

  • Configuration: /etc/sysctl.d/50-dirtybytes.conf
  • Settings: vm.dirty_background_bytes = 268435456, vm.dirty_bytes = 1073741824 (256MB / 1GB)
  • Benefit: Prevents the kernel from buffering massive amounts of "dirty" data in the 128GB RAM before flushing to HDDs, which eliminates system-wide stutter during large I/O tasks.

Redis Overcommit

  • Setting: vm.overcommit_memory = 1
  • Benefit: Necessary for Redis/Valkey background snapshots. Allows the kernel to grant memory fork requests even if it exceeds current estimated availability.

HTTP/3 & QUIC Buffers (Caddy)

  • Configuration: /etc/sysctl.d/99-caddy.conf
  • Settings: net.core.rmem_max = 7500000, net.core.wmem_max = 7500000 (7.5MB)
  • Benefit: Increases UDP receive/send window sizes, preventing packet drop and improving performance for modern HTTP/3 and QUIC connections through Caddy.

🎮 GPU Optimization (Quadro P2200)

Persistence Mode

  • Command: sudo nvidia-smi -pm 1
  • Benefit: Keeps the Nvidia driver loaded in memory regardless of active load. Eliminates the 1-2 second initialization delay when a container (Immich, OpenWebUI) calls the GPU for transcoding or inference.

🛡️ Future Considerations

  • PBO (Precision Boost Overdrive): To be verified in UEFI/BIOS for improved multi-core boosting.