Spotlight / mds CPU Usage on Mac OS X
Tuesday, January 5th, 2010I recently upgraded my 10.5.4 OS to 10.5.8. I’d been putting off updating the OS for a while since it’s one of the installations that I know always requires a restart, and I hate restarting. Despite the fact that my mac regularly does stupid things that necessitate restarting (protected memory is really useless against protecting the OS from application crashes if there is no protection from an application consuming all available memory for starters).
Now I consistently have to put up with mds / mdsworker consuming my entire CPU. Even when it’s not, it is often spamming my hard drive, and since that is the slowest component in the computer anyway, my computer slows to a crawl again. mds is the process for spotlight that crawls the hard drive indexing the files. Apparently this situation can happen with a corrupt Spotlight database. This wouldn’t surprise me, because with my 200G hard drive, the Spotlight DB grows to 18G and doesn’t stop. I run out of space then, so I remove the DB for / and it starts all over again.
Now, I’ve noticed that mds is actually run by launchd (a variation of cron). And launchd actually allows limits to be specified:
launchd limit cpu 100
Limits the CPU usage to 100%. This should, in theory, help. In practice, it’s hard to tell. I can’t tell how the limit is achieved. If it’s an average, it would permit a spike of 150% if followed by a 50% usage interval of the same time. Then the question becomes how long the calculation envelope is (the time interval for the average) to determine how long a 150% CPU usage (more than 1 core) spike actually is. I don’t have the information. I can see that sometimes launchd / mds is still using >100% and sometimes it isn’t, but it moves too quick for me to see if the average is hitting 100% or not. Oh well, was worth the try I guess.
I have a feeling that running my CPU at full load and my HDD constantly being railed, and for some reason my GFX is getting worked over as well, resulting in system loads consistently above 2 and permanent temperatures above 70 degrees celsius for the CPU and GFX, is going to result in my HDD dying soon. I have everything important backed up, but I certainly won’t be forking out $3000 for another Mac Book Pro if that happens. I haven’t had any problems with Windows 7, and if I do, it won’t be unexpected so I’m prepared for a reformat in that case. And it will cost be $2k less.