Skip to content

Instantly share code, notes, and snippets.

@geerlingguy
Last active December 4, 2025 03:33
Show Gist options
  • Select an option

  • Save geerlingguy/842974c0e49c201c28f4be54a05cc89c to your computer and use it in GitHub Desktop.

Select an option

Save geerlingguy/842974c0e49c201c28f4be54a05cc89c to your computer and use it in GitHub Desktop.
Get core-to-core latency graph via c2clat
# Make sure CPU is in performance mode (see notes in Gist comments).
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
# Install c2clat and gnuplot-nox
sudo apt install -y gnuplot-nox
git clone https://github.com/rigtorp/c2clat
cd c2clat
g++ -O3 -DNDEBUG c2clat.cpp -o c2clat -pthread
# Set up the PNG dimension (set to 4096,2160 for 96+ CPU cores)
echo 'set terminal png size 1920,1080' >output.gnuplot
# Run c2clat and create graph PNG
./c2clat -w -n "$(cat /sys/devices/virtual/dmi/id/board_{vendor,name,version} | xargs)" -p >> output.gnuplot
gnuplot-nox output.gnuplot >output.png
@geerlingguy
Copy link
Author

geerlingguy commented Oct 14, 2025

A few notes about running c2clat:

  • You can add -H to c2clat to warm up CPU cores for 200ms before beginning the measurement.
  • You can add -w to use write cycles instead of read cycles for measurement.
  • Set CPU cores into performance mode with echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
  • Some modern SoCs combine multiple types of cores, between GPU, CPU, and NPU, and due to the complexity of clocking and energy efficiency, just setting scaling_governor to performance on the CPU might not set everything to the highest power mode... To ensure all CPU governors are in performance mode, you can use sbc-bench.sh by running:
    sudo su
    wget https://raw.githubusercontent.com/ThomasKaiser/sbc-bench/refs/heads/master/sbc-bench.sh
    source ./sbc-bench.sh
    HandleGovernors performance
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment