Raspberry Pi 4 Advanced Overclocking
More than 30% more performance boost for free? The original Raspberry Pi 4 has a lot of room for overclocking, provided you add a little extra cooling.
Overclocking your Raspberry Pi normally uses more power. Every clock cycle requires a blip of electrical charge, so increasing the frequency increases the current proportionally. Compounding that effect is the increase in voltage required to push the current through the chip fast enough. The chip gets hot and we have to add heat sinks and even fans to be able to run at 100% CPU without hitting thermal limits and having to slow down. Whew!
This is fair enough - we can't fight physics. What would be great though, is if we could reduce both the frequency and the voltage when we're not running at 100%. Current firmware in Raspberry Pi 4 and its ilk 1 implement a cool 2 new feature called Dynamic Voltage and Frequency Scaling, or DVFS. It provides finer-grained control of CPU frequency and automatic scaling of voltage to match.
Without this feature, overclocking your Pi would give you better peak performance at the cost of higher idle power usage - especially at higher values of over_voltage. Being able to run headless Linux servers 24/7 at minimal [#cost] cost is my favourite thing about Raspberry Pis. I have a surprising number of them running in my house and garage. Up to now I've avoided overclocking non-interactive systems to be as efficient as possible.
Let's see if we can measure the difference!
A nice little Raspberry Pi 4B with 2GB RAM shall serve as our victim. We'll measure power loads under load and idle in various scenarios and see if we can draw any conclusions.
Idle: 0.6GHz 2.7W 0.8938V
Disable WiFi & Bluetooth
Deactivate (or de-solder!) Power and Activity LEDs
No Overclock: DVFS at 1, 2, and 3
Idle: 2.3W 0.6GHz 0.8388V 100% CPU 3.0W 1.5GHz 0.8938V dsa 2048 bits 0.002235s 0.002000s 447.4 500.1
400% 4.4W 1.5GHz 0.8938V dsa 2048 bits 0.000561s 0.000521s 1782.1 1920.7
1,000,000 games of snakes and ladders
No overclock: 3.4W 56.5s 1.5GHz 0.8938V DVFS overclock: 4.1W 42.9s over_voltage=6 4.3W 42.9s 2.0GHz 1.0438V
2GHz Overclock: DVFS vs over_voltage
DVFS=1 with 2GHz would not boot
Idle: 0.6GHz 2.3W 0.8938V 1-core 100%: 2.0GHz 3.5W 1.0038V 4-cores 100%: 2.0GHz 6.2W 1.0038V
dsa 2048 bits 0.001676s 0.001530s 596.5 653.6 dsa 2048 bits 0.000421s 0.000386s 2374.6 2593.7
Idle: 0.6GHz 2.5W 1.0438V 1-core 100%: 2.0GHz 3.7W 1.0438V 4-cores 100%: 2.0GHz 6.6W 1.0438V
dsa 2048 bits 0.001675s 0.001524s 597.0 656.0 dsa 2048 bits 0.000421s 0.000385s 2375.5 2594.2
Trying a different CPU governor in the OS
From the horses mouth:
The default CPU governor is ondemand, the governor can be manually changed with the cpufreq-set command (from the cpufrequtils package) to reduce idle power consumption:$ sudo apt install cpufrequtils $ sudo cpufreq-set -g powersave
frequency(48)=600169920 temp=43.8'C volt=0.8938V dsa 2048 bits 0.005579s 0.005244s 179.2 190.7 dsa 2048 bits 0.001405s 0.001288s 711.7 776.3
$ sudo cpufreq-set -g performance
frequency(48)=2000478464 temp=48.2'C volt=1.0038V dsa 2048 bits 0.001666s 0.001551s 600.2 644.7 dsa 2048 bits 0.000419s 0.000383s 2388.9 2608.91
Raspberry Pi 4 Model B, Raspberry Pi 400, and Compute Module 4 - all of the models using the newer BCM2711 SoC.2
Or maybe not so minimal! There are 8,766 4 hours in an average year. A five watt load running all year would use almost 9kWh, about $13 where I live. Multiply that by a herd and it starts to add up - as well as very slightly accelerating our terrifying fall towards the heat-death of the universe <https://en.wikipedia.org/wiki/Heat_death_of_the_universe>_.4
24 * 365.2425 average days per year in the Gregorian calendar, rounded up to the nearest integer.
Published 6 Oct. 2022