Pi Any Means Necessary #1: Overclocking and cooling
I’ve had a deep appreciation for the Raspberry Pi since it’s initial launch in 2012: the promise of a computer for the home that costs $35 (or, perversely, £35) made the possibility of a universally available and affordable computer for people’s homes a far more realistic one than it had been in my youth of attempting to learn everything I could about computers from stolen hours in public libraries and borrowed and outmoded hardware.
I’d picked up Pis for projects in the past and not really used them in the capacity of a real ‘desktop’ computer, but rather used them as headless devices to act as servers and the like at a more reasonable power consumption than a full x86 device. I realised that I’d not had that ‘real’ daily-driver type experience with a Pi - in spite of my appreciation of the goal of such a cheap device being capable of acting as such - and decided to set myself the challenge of using a Raspberry Pi 4 8GB as my primary computer.
So with the variant of the Pi I was going to use chosen, I still had some choices to make regarding what I was going to do in terms of the software I was going to run on it, any accessories for this ‘project’ and how best to configure everything for as good an experience as I could get. Being a person able to make sound prioritisation decisions, I’d started with the ‘accessories’ question.
Over the years, I’ve been exposed to an awfully large number of novel homes for the Raspberry Pi, and I couldn’t be more susceptible to the idea of a cute home for my little computing pal. I’d come across the 52Pi ZP-0130, a case for the Pi that includes a case with an OLED screen on the front of it, a cooler (the 52Pi ICE Tower, replete with an RGB fan) for the Pi and a board that would allow me to connect a SATA M.2 SSD - one of which I had hanging around in a drawer with no idea where it had come from.
I was curious to see what the benefit of having such a large heatsink and fan on the Pi would be, knowing that the processors have a habit of generating quite a bit of heat, so used stressberry, sysbench, openssl’s benchmarks and 7-Zip’s benchmark to understand a little better what I gain from each stage in the evolution from Pi with no cooling, to Pi with passive cooling from the heatsink to Pi with heatsink and fan.
First, invoking stressberry with stressberry-run --duration 900 --idle 120
to have the processor just do a lot of work that doesn’t amount to anything but generating heat:
We see that we get a fair amount of throttling at around 80 degree Celsius and upwards: at that point, the processor becomes throttled in an attempt to prevent any thermal damage. Bearing in mind that this is - at the moment, at least - how a Pi comes from the factory, the need for some sort of cooling system becomes clear.
Having installed the heatsink, I ran the same stressberry test:
Once our test starts at 120 seconds in, the CPU hits the stock 1.8GHz and doesn’t become throttled at any point during the test. It also doesn’t hit anywhere near the same temperatures: having a fairly sizeable chunk of metal on top of the processor draws heat away from it. Who would have thought.
While the heatsink seems sufficient at 1.8GHz, I was curious to see what effect turning the fan on would have on the thermals of the Pi. Running the same stressberry test again:
It turns out that the combination of a large metal block to transfer the heat away from the processor combined with using the movement of air to get the heat away from the heatsink is a tried-and-true combination for cooling CPUs. Given the fetishisation of the enthusiast community for water-cooling, this may be news to some. With the fan turned on, our temperatures never break 50 degrees Celsius.
But what does this mean for ‘real-world’ performance? Well, as close as we can get to ‘real-world’ performance with some synthetic benchmarks? For all values in the table below, higher is better.
Configuration | Sysbench 8-thread CPU test (events/s) | 7-Zip multithreaded benchmark Decompressing (MIPS) | 7-Zip multithreaded benchmark Compressing (MIPS) | OpenSSL SHA256 on 16k blocks (1000s of bytes/s) |
---|---|---|---|---|
No heatsink, no fan | 7141.39 | 7194 | 3466 | 170033.15k |
Heatsink, no fan | 7953.79 | 7967 | 3760 | 187899.19k |
Heatsink and fan | 7961.10 | 8083 | 3920 | 189683.03k |
We see that for each of the tests, heatsink outperforms non-heatsink configurations by around 5-10% in each of these tests, with fan and heatsink configurations performing marginally better again, but perhaps only within a margin of error. This is broadly what we’d expect to see given the fact that we don’t see any throttling in any configuration that involves the heatsink.
If I’m using the Pi as my primary computer, I want to give it the best possible chance that I can to get the most that I can out of the board. With that in mind, and with how trivial it is to overclock the Pi with little more than a couple of changes to a config file, I went ahead and added the following to the Pi’s /boot/config.txt
:
arm_freq=2200
gpu_freq=750
over_voltage=8
This represents an overclock of 22.22% from the stock clock speeds of the Pi at the cost of applying a little more voltage and perhaps drawing a little more power from the wall: if you’re doing this, please make sure you’re using a decent power supply. I then ran stressberry again to ensure that the now-definitely-hotter CPU was still running in a way that wouldn’t lead to it being throttled:
Remarkably, even with the overclock, this cooling solution only goes around 10 degrees Celsius hotter, and the Pi seems to run stable with it. We appear to have gained a theoretical 20% performance improvement for ‘free’! Running our benchmarks again:
Configuration | Sysbench 8-thread CPU test (events/s) | 7-Zip multithreaded benchmark Decompressing (MIPS) | 7-Zip multithreaded benchmark Compressing (MIPS) | OpenSSL SHA256 on 16k blocks (1000s of bytes/s) |
---|---|---|---|---|
Heatsink and fan | 7961.10 | 8083 | 3920 | 189683.03k |
Heatsink and fan, overclocked | 8756.07 | 8808 | 3986 | 208939.69k |
So maybe not quite 20%, but ~10% is nothing to be scoffed at for the price of a configuration file change!
Appendix⌗
The following commands were invoked for each of the tests:
Sysbench: sysbench cpu --threads=8 --time=120 run
7-Zip: 7zr b
OpenSSL: openssl speed -evp sha256