This document provides an overview of performance optimization techniques for Linux. It discusses optimizing at the application, hardware, and Linux environment levels. At the application level, it recommends fixing bugs, compiling with optimizations, using multi-threading efficiently, and structuring the program for the hardware and Linux. For hardware, it suggests selecting hardware for the task and tuning software based on the specific hardware. And for Linux, it discusses profiling and benchmarking tools, as well as optimizing specific components like CPU, I/O, memory, power management, and networking.
2. Intro
What do you want to learn today?
What level are you interested in? Any specific
requests? Have you ever optimized Linux or an
application for Linux?
Assuming everyone is familiar with Linux
concepts and basic architecture
4. Methodology
Document
Start on a clean system
Empty caches - warmup caches
Automate testing (clear caches every time)
Step-by-step
Keep those changes which are significant
Establish baseline
Think about side-effects
Avoid trial-and-error
6. Application
Fix bugs! aka. optimize last
Run at least -O2
Multi-threading
Structure the program to be efficient on the
hardware and Linux
structure size alignment (cache-line, IO)
are all POSIX/OS features used?
If in doubt test!
7. Hardware
Select hardware for the
task
Study the hardware you’ve
selected: CPU, HT, memory,
NUMA, SSD, disks, iGPU,
TDP/SDP
Tweak the SW for the HW
(think SSE, AVX)
Tune HW specifics through
/sys
9. Linux interfaces
Run up-to-date (OS+gcc+libs)
/proc - more OS
/sys - more HW
sysctl
kernel command_line
kernel config
top, ntop, iotop
vmstat, iostat
uname
15. Power Management
consolidate old hw -> virtualize
scheduler
powertop
turn off unused hardware (isolcpus, network)
scheduler (use tickless)
C states
P states: frequency-voltage combinations
16. Networking
Throughput or latency (RT Linux?)
use your HW
verify link speeds
segmentation offload
network buffers
per socket buffers
zero copy
TCP congestion control algorithms
tools: ethtool, iperf, netstat, wireshark!