Curing Mac’s High CPU + Fan Noise + Heat

Photo by Immo Wegmann on Unsplash

TL;DR: Jump to Troubleshoot

Have your relatively new Macbook Pro’s fan gotten into turbo mode when having a simple zoom meeting? Or with doing nothing, cpu would constantly be utilized and the case just always feels too warm. Or between each Time Machine backup, while only browsing the web, it tries to backup Gigs of data you have no idea why.

God forbid, if you try to actually edit photo or compile code, the fan will max out at 6000+ rpm which would cause actual disruption to your zoom meeting. If you have such cases, maybe this article can help a bit.

I’m a devops by trade, which usually troubleshoot performance issue of larger system and code. However, this high cpu usage issue has been plaguing my 2018 MBP 13" since I got it and only until this Thanksgiving week, I was fed up enough that I tried to get to bottom of it.

It’s not without previous tries of troubleshoot, but just not enough time spent to it, always had some project more important than dealing with laptop issue. It’s not until I turned my laptop to Apple for fixing a known keyboard issue and replaced a short-lived battery(212 Cycles Only), I used my old 2011 Mac Mini for a week. And to my surprise, this 10 years old machine rarely kicks off fan and it was fast enough to do my work. Albeit, I did upgrade memory to 16GB and swap out old HD with SSD, but it was stable and QUIET.

That got me thinking, it must be software issue that’s causing the cpu to be busy. Time to use my system administrator skill on this noisy laptop.

Troubleshoot

*For reference, this is tested on 2018 MBP 13" with Big Sur.

First, in order to know what’s going on, we need a way to see what’s chewing up the CPU. I prefer command line most of time. So open a terminal and type top and see which process is using cpu. This is important, as this is the way we determine what to troubleshoot and determine outcome.

What I have seen causing major cpu spikes for my system:

  • Metadata related process(mds, mdsync, mds_store, mdworker). This is related to spotlight as it tries to index any changes to files. This also relates to Time Machine backup when mds tries to index local snapshot of Time Machine.
  • coreaudiod. Audio daemon that sometimes app doesn’t release audio properly causing the audio daemon continuously take on cpu.
  • Browser process(com.apple.WebKit or Chrome). This is related to certain tabs or pages in the browser that’s taxing cpu hard.
  • WindowsServer. This is related to application that’s drawing complex stuff which causes cpu spike.
  • kernel_task. This is a special process that Mac kicks off when it detects system is running too hot.

In general, run top to see system utilization. You can also press i and then mem to sort by memory usage. Sometimes when memory ran out, CPU will be busy swapping content from memory into disk.

Resolution

Metadata related process. I’ve seen this a lot, different metadata process that reads lots of files and index them. If you are seeing those process constantly running, it’s possible that existing index is either corrupted or your files are constantly changing which is causing the index to run constantly. To find out what the process is doing, use following command to see what files it reads or writes.

# Well known metadata process
sudo fs_usage -w -f filesys mds_stores
sudo fs_usage -w -f filesys mds
sudo fs_usage -w -f filesys mdsync

And you’ll see result like this which shows what operation and what files mds is working .

18:59:53.182239  getattrlist                            /System/Volumes/Data/usr/local/var/mongodb/diagnostic.data/metrics.interim                                                                                            0.000062   mds.1775007
18:59:53.182264 listxattr /System/Volumes/Data/usr/local/var/mongodb/diagnostic.data/metrics.interim 0.000012 mds.1775007
18:59:53.182359 getattrlist /System/Volumes/Data/usr/local/var/mongodb/diagnostic.data/metrics.interim 0.000078 mds.1775007
18:59:53.182826 getattrlist /usr/local/var/mongodb/diagnostic.data/metrics.interim

In my case, I see that it’s reading a lot of brower cache file from Chrome from ~/Library/ which is not good since I never search anything from cache file. Also, the same constantly changing files are causing Time Machine to backup stuff that I don’t really care. What I suggest was putting those constant change folders on the exclude list for both spotlight and Time Machine. Go to “Finder” and click on ‘GO’ -> ‘Go To Folder’, then type in ~/Library and it will open the folder. Sort the folder by “Date Modified” and observe what’s constantly change

Time is 6:59PM and you can see bunch of folder just

Determine what you don’t need to index and backup. Open up Spotlight preference, click on “Privacy” and drag any folder you don’t want to index into the pane.

Also drag those folders into Time Machine exclude list so it doesn’t get backup constantly which also uses CPU to calculate what to backup.

Exclude files for backup

Also use the following command to see what Time Machine will try to backup next time. The last parameter is from time machine volumes.

# Suppose to calculate size of backup, but I always get 0 bytes.
malin ~/dev/kloktech $ tmutil calculatedrift /Volumes/.timemachine/276ADFF2-901A-4279-A403-618CB21887CB/2021-11-08-234632.backup/
# See the backup
malin ~/dev/kloktech $ tmutil listbackups
2021-11-09-222606.backup
2021-11-10-203518.backup
2021-11-11-183659.backup
# To see size of earlier backup backup
malin ~/dev/kloktech $ sudo tmutil uniquesize /Volumes/.timemachine/276ADFF2-901A-4279-A403-618CB21887CB/2021-11-08-234632.backup/2021-11-08-234632.backup/
6.9G /Volumes/.timemachine/276ADFF2-901A-4279-A403-618CB21887CB/2021-11-08-234632.backup/2021-11-08-234632.backup# Delete older backup, note the format.
sudo tmutil delete -d /Volumes/.timemachine/276ADFF2-901A-4279-A403-618CB21887CB/2021-11-08-234632.backup -t 2021-11-08-23463

To fix corrupted index, turn off index, then turn it back on. mds will re-index everything which would take 10–30 mins depending on how much files there are.

# Check current index status
sudo mdutil -avs
# Turn off index for all disk. '-a' applies to all disk
sudo mdutil -a -i off
# Turn on index.
sudo mdutil -a -i on
# You can turn off indexing for specific disk.
sudo mdutil -a -i off /Volumes/external_disk

If you have time machine, you will seeing something like in output of index status.

malin ~ $ sudo mdutil -avs
/:
Indexing enabled.
/System/Volumes/Data:
Indexing enabled.
/Volumes/.timemachine/NAS._smb._tcp.local/E4D6C7AD-A9BF-4CD8-8B78-744FDCC44B6D/TM-Mark:
Indexing and searching disabled.
/Volumes/Backups of Mark-MBP:
Indexing enabled.
Scan base time: 1970-01-01 00:00:01 +0000 (1638326378 seconds ago), reasoning: '(null)'

Notice “/Volumes/Backups of Mark-MBP”, that’s folder with local snapshot used by Time Machine and it’s supposed to have index turn on in order for TM to work.

Also something to note is that ‘/’ and ‘/System/Volumes/Data’ both needs to be indexed in order for spotlight to find files and preferences. I turned off indexing on ‘/System/Volumes/Data’ hoping it would reduce mds cpu usage, but without index on that volume, spotlight have not much to search on.

Coreaudiod. Some application would cause audio daemon to continue running after audio stop playing. Open a terminal with top running, and close application one by one until you find which app is cause coreaudiod to hog cpu. Usually restart the app would cure this problem. In my case, it’s usually the instant messenging app ‘Line’ that causes the issue.

Browser process. Sometimes some page has crazy code or heavy graphic that would cause cpu to run hot. If you see chrome or WebKit in top, use browser’s task manager to find out which tab is using lots of cpu and close them.

WindowsServer. This is related to application that’s drawing complex stuff which causes cpu spike. This is similar to web pages that cause cpu hike, but in this case, it’s some application that doing heavy drawing. In my case, when messenging app “Slack” has animated emoji option turned on, it sometimes cause WindowsServer to draw lots of CPU.

kernel_task. This is a special process that Mac kicks off when it detects system is running too hot. It cools down system by occupying cpu cycles that does nothing so other process can’t utilize more cpu. However, it isn’t always trigger by high cpu usage. Supposedly, port that power plugs into affect temperature too. On MBP 13, looking at monitor, left side ports would trigger fan because there is thermo sensor there. I tried both side without seeing much difference. When this process is doing 10% or higher cpu, that means your system has deemed itself being too hot and fan will kick off. If you use laptop with closed lid and external monitor, you’ll see this process often. I guess close lid would cause higher temperature than open lid.

And that’s it! Hopefully, as each cpu chewing process gets tame, you’ll get a nice cool laptop with better battery life to work with.

APPENDEX

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store