Cheat SheetsLinuxPerformance

Performance — Cheat Sheet

Linux · 1 topics. Download the PDF or the Instagram carousel and share it.

Cheat Sheet · AiCanCode.org
Performance
Linux1 topicsQuick revision reference
1

Linux Performance Monitoring

Profile CPU, memory, disk I/O, and network using vmstat, iostat, sar, perf, and flame graphs. Understand load average, context switches, and I/O wait to diagnose production bottlenecks.

  • Load average > number of CPUs = CPU saturation — processes are queuing for CPU time.
  • "available" in free -h is the real usable memory — "free" excludes reclaimable cache.
  • Non-zero swap out (vmstat si/so) = memory pressure = significant performance impact.
  • await in iostat = average I/O request latency — high await = disk bottleneck.
  • iostat util% = 100% = device saturated = I/O bottleneck — upgrade storage or reduce I/O.
  • Exhausted inodes (df -i shows 100%) cause "no space left" errors even with free disk space.
bash — CPU monitoring with uptime, vmstat, perf
# Load average
uptime
# 10:30:05 up 5 days, 2:15, 2 users, load average: 1.25, 0.87, 0.64
#                                                    1min  5min  15min
# Rule: load average / number of CPUs = saturation
# 1.25 load on a 4-core system = 31% saturated (healthy)
# 8.0  load on a 4-core system = 200% saturated (heavy queue)

nproc                    # number of logical CPU cores
lscpu                    # full CPU info (cores, threads, NUMA)

# vmstat — virtual memory statistics
vmstat 1 5               # 5 samples, 1 second apart
# procs  memory          swap  io    system     cpu
# r  b   swpd   free      si  so    bi  bo      in  cs   us sy id wa st
# 2  0   0    512000     0    0     100 200   1500 2000  40 10 45 5  0
# r: runnable (queued) processes — if consistently > nproc, CPU saturated
# b: uninterruptible sleep (waiting for I/O) — if high, I/O bottleneck
# wa (cpu): % time waiting for I/O — high wa = disk/network bottleneck
# cs: context switches per second — very high = too many threads/processes
# us: user CPU, sy: kernel CPU, id: idle

# CPU profiling with perf
perf top                 # real-time CPU profiler (which functions are hot)
perf record -g ./myapp   # record call graph
perf report              # analyze recorded data
Learn this free with Aria, your AI tutor → AiCanCode.org/learn/linux