Tuesday, September 30, 2014

Raspberry Pi - Overclocking

I have worked with computers professionally for 20 years now, yet in all that time I have never once experimented with overclocking and/or thermal management.  Given that the 1) Raspberry Pi is so easy to overclock, 2) it is relatively cheap to replace should I break it, and 3) the whole idea behind the Raspberry Pi is to be used as an education tool; this seems like the perfect time for me to experiment.

Before purchasing my Raspberry Pi I researched it and the general consensus is the Raspberry Pi does not need heatsinks unless you are trying to overclock to extreme levels.  I wanted to test this for myself, so I purchased a set of heatsinks shown here.  What is nice about these heatsinks is they are made of copper (which conducts heat better than aluminum) and they have tall fins for maximum heat dissipation.  So this should be the most effective passive cooler for the Raspberry Pi.

As far as overclocking, the creator of the Raspberry Pi, Eben Upton, said that overclocking your Raspberry Pi will not damage it, but overvolting it may.  As such, overvolting voids the warranty (and they will know because of a burned out internal fuse).  So I plan to avoid overvolting, which also limits how much overclocking I can do.

Overclocking is accomplished by setting values inside the config.txt.  There are a lot of values you can tweak, but there are 3 main settings.

  1. arm_freq = The frequency of the CPU.  The default value is 700.
  2. core_freq = The frequency of the GPU.  The default value is 250.
  3. sdram_freq = The frequency of the RAM.  The default value is 400.
I started playing with these numbers, and I noticed something odd.  I could crank the speed up higher than most people on the Internet reported and I had no problems with stability nor extra heat generation.  Was the model B+ significantly improved in this area?  Turns out the answer is no.  By default the Raspberry Pi (like all modern processors) has a base line and a "turbo" frequency.  It runs at the above default values and only switches to the overclocked values when the CPU reaches a certain use threshold.  There is an additional setting called "force_turbo" that disables this dynamic switching and forces the Pi to always run at the overclocked values.  I recommend enabling this "force_turbo" setting, at least during initial testing.

When you overclock the Pi there are two concerns.  First is heat generation, you need to make sure the CPU is thermally cooled (more on that later).  The second problem is SD card corruption.  Some overclock settings are not stable and the result in corrupted SD cards.  The reason I recommend enabling "force_turbo" during testing is because then it will force SD card corruptions to happen more frequently if you are using unstable overclocking settings.  But with "force_turbo" disabled the Raspberry Pi will run at slower speeds most of the time even if the overclock settings are unstable.  The long term result would be random crashes that would be hard to diagnose.

Ok, so let us put this all together.  The first question is, does overclocking make a performance difference, and if so how much.  For this I used sysbench which can stress the CPU calculating prime numbers.  At the default 700/250/400 settings, it took 8:29 to calculate the first 10,000 primes.  When overclocked to 900/300/400 this dropped to 6:34 - approximately 25% faster.

As for thermal, during the initial 700/250/400 the starting temperature was 106°F (41°C) and went up to 109°F (43°C).  Overclocked to 900/300/400 the starting temperature was 106°F (41°C) and went up to 111°F (44°C).  As you can see, the temperature increase was very small.  In all of my tests, overclocking added about 2°F (1°C).  Given this small increase in temperature versus the noticeable gains in performance, it makes sense to overclock your Pi.

Lastly I was curious how much of a difference the heatsink made.  I repeated all of my tests this time with the heatsinks attached.  The change was minor but consistent.  Adding the heatsinks reduced the temperature by 2°F (1°C).  In addition to the minor drop in temperature, I noticed temperatures rose less sharply than they did without the heatsinks, and when the load dropped off the CPU cooled off quicker.

I was curious if forced air (like a fan) would make a difference.  The answer is most definitely yes!  In fact, this is far more effective than a heatsink.  Merely blowing on the CPU cooled the processor more than the heatsink ever did.  So if you are looking to seriously overclock your Pi, you need to look into a fan solution, with or without a heatsink.


Conclusions
After all of my tests, here are my conclusions.
  1. Everyone should at least mildly overclock their Raspberry Pi.  Set it to 800/250/400 with force_turbo disabled.  You will not damage your hardware, nor will it overheat, but you will see speed improvements under load.
  2. If you are looking for a little more speed (like me), then set your CPU between 800 and 900, bump the GPU to around 300, and try increasing the RAM to 450.  Be sure and set force_turbo at least during the testing to make sure it is stable.
  3. At these overclock settings, it will run a degree or two warmer, which is exactly how much cooling is provided by the heatsinks.  So think of the heatsinks as piece of mind, they perfectly balance out the slight overclocking.
  4. If you wish to overclock to extreme levels then you will most likely need fans and probably overvolting as well.  So proceed at your own risk.

No comments:

Post a Comment