|
| 1 | +```@meta |
| 2 | +CurrentModule = BLASBenchmarks |
| 3 | +``` |
| 4 | + |
| 5 | +# Disabling CPU Turbo |
| 6 | + |
| 7 | +Most recent CPUs have the ability to turbo, increasing their clock speeds for brief durations of time as thermal envelope and longer term power-use limitations allow. This is great for performance, but bad for benchmarking. |
| 8 | + |
| 9 | +If you're running Linux, it's probably easy to enable or disable turbo settings without having to reboot into your bios. |
| 10 | +The Linux Kernel Documentation is fairly thorough in discussing [CPUFreq](https://www.kernel.org/doc/html/v4.12/admin-guide/pm/cpufreq.html) and [intel_pstate](https://www.kernel.org/doc/html/v4.12/admin-guide/pm/intel_pstate.html) scaling drivers. |
| 11 | + |
| 12 | +To check those on my system, I can run: |
| 13 | +```sh |
| 14 | +> cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_driver |
| 15 | +intel_pstate |
| 16 | +intel_pstate |
| 17 | +intel_pstate |
| 18 | +intel_pstate |
| 19 | +intel_pstate |
| 20 | +intel_pstate |
| 21 | +intel_pstate |
| 22 | +intel_pstate |
| 23 | +``` |
| 24 | +This tells me it is using `intel_pstate` in active mode. |
| 25 | + |
| 26 | +The documentation on `intel_pstate` mentions the `no_turbo` attribute: |
| 27 | + |
| 28 | + |
| 29 | +> If set (equal to 1), the driver is not allowed to set any turbo P-states (see Turbo P-states Support). If unset (equalt to 0, which is the default), turbo P-states can be set by the driver. |
| 30 | +
|
| 31 | +This attribute is writable, so running |
| 32 | +```sh |
| 33 | +echo "1" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo |
| 34 | +``` |
| 35 | +disables turbo on this system. This, and closing programs that would compete for system resources (e.g., internet browsers; you can run `(h)top` to see if any processes are consuming non-negligible resources), should hopefully make benchmarking reasonably consistent and reliable. |
| 36 | + |
| 37 | +Finally, when I'm done benchmarking, I can reenable turbo by running: |
| 38 | +```sh |
| 39 | +echo "0" | sudo tee /sys/devices/system/cpu/intel_pstate/no_turbo |
| 40 | +``` |
| 41 | + |
| 42 | +If your system does not use the `intel_pstate` driver, check for |
| 43 | +```sh |
| 44 | +/sys/devices/system/cpu/cpufreq/boost |
| 45 | +``` |
| 46 | +discussed [here](https://www.kernel.org/doc/html/v4.12/admin-guide/pm/cpufreq.html#frequency-boost-support) in the kernel documentation. If the file is present, you should be able to disable boost with |
| 47 | +```sh |
| 48 | +echo "0" | sudo tee /sys/devices/system/cpu/cpufreq/boost |
| 49 | +``` |
| 50 | +and then reenable with |
| 51 | +```sh |
| 52 | +echo "1" | sudo tee /sys/devices/system/cpu/cpufreq/boost |
| 53 | +``` |
| 54 | + |
| 55 | +In either case, you may find it convenient to place these snippets in `#! /bin/bash` scripts for conveniently turning your systems boost on and off as desired. |
| 56 | + |
0 commit comments