The following article details how, under load, my MacBook (Pro Retina Mid 2012 2.6GHz Intel i7 with 16Gb) was less than 1/4 of the speed it used to be and how I fixed it.
Over the last few months I started to notice that things were becoming less responsive in my dev environment, that’s an understatement, it was beginning to crawl. Something needed to be done or I needed a new machine!
Recently I’ve switched to doing most of my developing inside the virtual machine using UnityVS as for some reason since upgrading to Mavericks 90% of the time I try to debug something in unity with monodevelop on the Mac it crashes. Let me know if you have the same issue or not! Anyway it’s lovely to be back in visual studio and debugging in it works.
Improvement 1 – Windows Update Error
So my first attack at speeding things up was task manager, somehow the CPU would hit 100% with just the editor open and visual studio but doing nothing. After a lot of searching and failed attempts to find the culprit I did improve this slightly (I think) after discovering that one microsoft update kept failing to install. It turned out to be part of Windows 8.1 so despite windows reporting that 8.1 was installed it wasn’t completely. On the start screen I had no power or search icons in the top right but KB2919355 was failing so I downloaded the update manually and ran it which actually worked. After that Windows update found a load of other updates which I installed. All up to date and windows was at least working more responsively now, although not great.
Identifying the real issue – heat & under clocking
After a few more days I was still not happy and had been running with task manager and the Mac activity monitor visible frequently the machine would crawl, creating builds was beginning to take 10’s of minutes. When I switched build platforms Unity took over an hour to convert files!
My Mac was hot to touch and I started to wonder if it was down clocking the cpu, I came across the Intel Power Gadget which shows you the actual clock speed of your processor on a graph. This was a real eye opener!
When the CPU load went up in activity monitor the cpu frequency went down. In fact my cpu would be between 1.0 and 0.8 GHz! The temperature of the CPU also shown stayed at a constant 75 degrees C. So I concluded that when there was a lot of load on the processor and all cores were active etc the clock frequency was cut to stop the machine from overheating. As soon as there was not much to do the CPU would bounce back up to 2 GHz and occasionally higher and into 3GHz territory, but usually below 2.6 and nearer 2.
An interesting temporary solution – use fewer cores = faster machine.
So when under load the cpu would quarter it’s speed! When I had enough work to keep all cores busy (let’s say 4 times the normal work) everything slowed down, but there was still 4 times as much work. Meaning that standard operations would now take 4 * 4 as long 16 times! No wonder I thought things were getting sluggish.
So I reconfigured my virtual machine to restrict it to use two cores and this did indeed make everything much better as the machine was under less load and hence kept the processor speed higher most of the time and as a result the windows machine despite having fewer cores was considerably faster! How mad, but understandable.
Solve the overheating
I started to look into fans and monitoring the fan speed using iStat a great app, I tried and bought several others but this was by far the best. The fans were going at maximum speed when the processor was under load, I set iStat to the high fan setting to keep the fans at maximum at all times. This may have reduced the cpu temp slightly when idle but I didn’t notice much difference in performance. I’m still experimenting with this but I think the algorithms that manage the fan speed also manage the cpu speed and as such do an effective job of not running fast when they don’t need to but ramping up as soon as they do.
Since I remembered this machine used to be blazingly fast and it had slowed down over time it perhaps it was as simple as a build up of dust in the fans? Typically apple use their own screws so I ordered:
- iFixit Pro Tech Toolkit – For the pentalobe screwdriver bit required to open the macbook.
- Manual air blower – for the majority of dust
- Compressed air – for the more stubborn dust.
Now on the quest to keep my Macbook cool I also researched cooling stands and ordered the following:
Laptop cooler – results
This arrived first. I chose this model as it allows me to position the fans to cool the areas of the macbook that get warm. I’m not sure what affect it will have as the macbook draws in it’s own air from the sides and spits it out at the back below the screen, but the underside of my mac gets reasonably warm, not as warm as above the keyboard though!
If you’re looking for a cooler, this is good fit for the macbook just around a cm smaller around the edge so that it’s not visible when the laptop sits on it and the rubber is enough to stop the laptop slipping down.
The fans are quiet enough to not be noticeable in an office with other equipment, take it into a separate quiet room and you can hear them but they are no more noisy than the mac it’s self and you can feel the air that they push towards the machine. Build quality is good and I actually like the elevation it places the Mac at. So now what affect does it have?
Well, this is really quite interesting. What appeared to happen was that the CPU temperature sensors started reading higher values and constantly ran at 80 – 100 degrees C. Not what I was expecting, but actually it’s good news as the clock speed started to average above 2.6GHz often around 3.2GHz. Although under load the machine would still start to crawl and down clock but this happened less often. My conclusion here is that the algorithms used to control the internal fans and clock speed are quite clever, I’d love to find an article on them… So I’m assuming that the added cooling mean’t that the machine was more comfortable at running the machine at a higher internal temperature as I’m guessing that the other temperature sensors closer to the case were reading lower values, informing the algorithm that it could dissipate the heat quicker. I did not test this as I had only been concentrating on the CPU temperature. Anyway the cooler seemed to have the desired affect of speeding up the machine, even if the machine in parts ended up being hotter!
The final fix – dust bunnies
So my iFixit toolkit turned up today. I was a bit apprehensive after reading some amazon reviews complaining about poor quality, although all that did got good quality replacements from iFixit directly. It appears from reading the reviews that there are two sets out there, I ensured that I ordered from iFixit (via amazon).
I opened it and inspected everything and I must say I’m quite impressed with the quality. The tweezers are the best I’ve seen and the screwdriver set feels of quality.
Anyway the moment of truth, time to open the mac up. After letting it cool down in the off state for a while I touched a few metal things to ensure I had no static build up and carefully undid the 10 screws. Note that the back centre two are a different size to the others, as always I placed the screws in the order I took them out so that when replacing the same screws would end up in the same place. So would it be dusty?
So I used my air blower to get rid of most of the dust and the tweezers for large bits that were stuck. Then I used the air duster / compressed air to get rid of the last few bits. When using this make sure you keep the can upright and bend the plastic straw to direct the air. The results are below, it looks all clean like new again:
All put back together I booted it up and ran the Intel Power Gadget. After 30 min or so it was still running 20 degrees cooler than it had previously. Also the clock frequency was constantly between 3.2GHz and 3.4GHz which really surprises me as the machine is sold as a 2.6GHz, I guess turbo boost is used a lot more than for short boosts, which is fantastic.
Anyway I thought I’d test what it was like under load and the results put a huge smile on my face. I used Geekbench 3 which previously took tens of minutes to complete it’s tests as the cpu dropped to 0.8GHz. This time it flew through the tests taking a couple of minutes!
As the screenshot of the whole timespan shows the CPU ran at a pretty much constant 3.4GHz for the duration of the test, where the line starts to fluctuate is after the tests had finished.
It’s like I have a brand new machine! Now instead of .8GHz I get 3.4GHz
A 425% sustained speed improvement!
I can now get back to using my machine like I used to running the following:
On the Mac side:
Unity3D, Monodevelop, Photoshop, Texture Packer, Plastic SCM, Mail, Word, Several web browsers open at once (Safari, Firefox, Chrome) with many tabs, I use a different browser for different clients so that the relevant logins etc are remembered.
On the windows side:
I also run a windows 8 machine in parallels configured to use 4 cores and 8Gb CPU memory, 1Gb GPU memory running:
Unity3D, Visual Studio, Plastic SCM
It powers the Retina display and two 27″ 2560×1440 displays so I guess you could say it has it’s work cut out. But it more than copes running the game in unity twice simultaneously in windows and mac!
I can’t quite get over how fast it is now, flipping between huge memory & CPU hungry programs is a breeze, yesterday I would only dare run a couple and switching took 10s of seconds, even watching a video in safari would stutter occasionally. Oh so happy.
I’m sure you’ve had that thought ‘This pc used to be faster’. I used to put it down to the number of installed operating system patches and other software etc, however now my first port of call is always going to be boot up the Intel Power Gadget (also available on PC) and check that the machine is operating at the expected frequency. If not open up the machine, and clean the cooling system.
Whilst manufacturer’s seem to make opening laptops very difficult (although the macbook was probably the easiest, after purchasing the right screwdriver, compared to some I’ve opened in the past) it appears that it should be on the yearly todo list of all owners.
Once open it’s also a relatively easy task, especially on the macbook as all the cooling is accessible, you don’t need to physically touch anything inside the computer.
Hope this helps, and you too can get that like new feeling with your old PC.