shlogg · Early preview
Franck Pachot @franckpachot

Using Perf On Linux For CPU Consumption Analysis

perf on Linux helps understand CPU consumption, mostly harmless on modern kernels but try it first in a test environment. Use perf record and script to gather samples, then load the file into Firefox Profiler for detailed analysis.

Using perf on Linux is a great way to understand your CPU consumption. It is mostly harmless on modern kernels, especially when running for a short time, but try it on a test environment first if you can.
Here is an example where I gather 99 samples per second, during 10 seconds, for PostgreSQL and YugabyteDB processes and threads:


ssh my.server 'sudo bash -c "
perf record -o - --call-graph fp -F99 -e cpu-cycles \
 -p $(pgrep -d, postgres\|yb-tserver\|yb-master) sleep 10 |
 perf script -F +pid
"' > $( date +%Y%m%d%H%M%S | tee /dev/stderr ).perf


    
    

    
    




This generates a fil...