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.
More on Performance & the USE Method
What is the USE method?BeginnerMap the USE method to concrete Linux commands.IntermediateWhat is your "first 60 seconds" checklist on a slow server?IntermediateHow do you read vmstat output?IntermediateHow do you read `iostat -xz 1`?IntermediateWhat is sar and why install sysstat on every server?Beginner