Interview Prep/Linux/Performance & the USE Method

How do you find what code is burning CPU with perf?

AdvancedProductionPerformance & the USE Method
Answer
sudo perf top -p <pid>                        # live hottest functions
sudo perf record -F 99 -g -p <pid> -- sleep 30
sudo perf report --stdio | head -50
sudo perf stat -p <pid> -- sleep 10           # cycles, IPC, cache misses

For flame graphs: perf script | stackcollapse-perf.pl | flamegraph.pl > cpu.svg. JIT runtimes need symbol maps (Java -XX:+PreserveFramePointer plus perf-map-agent, Node --perf-basic-prof). Sampling at 99 Hz keeps overhead low enough for production.

All Linux questions Roadmap: Linux

More on Performance & the USE Method