ExpanDrive Blog

Development news on ExpanDrive and Strongspace

Is MDS taking over your CPU on OS X? Try Spotless.

Jeff Mancuso June 24th, 2007

My 5 month old MacBook Pro often has the MDS process chewing about 45-50% of CPU at various points in the day. Given that MDS is supposed to sit around and casually index – so that Spotlight can quickly perform a search, this CPU usage pattern is a red flag. Chances are something is wrong with either the disk or the Spotlight metadata index [what MDS manages]. After using Disk Utility to verify the volume, I tried Spotless. It worked great.

spot10.jpg

Spotless is a nice little $15 nagware utility made by Fixamac Software that helps you delete and recreate the Spotlight metadata folder and index, so that it can let MDS rebuild from scratch. It offers a few other moderately useful features, but if MDS is getting aggressive, this makes it real easy to get a clean rebuild.

Update 8/11/09: JS points out comments that you can instruct MDS to clear out the metadata cache and rebuild from scratch using this command run from Terminal:
sudo mdutil -avE

This is effectively what Spotless does, but without the user interface.

  • Carlos

    JS Thank you very much! I suffered the agony of a slow mac for two weeks, countless hours trying to figure this thing out. Thanks again.

  • Jeremy Pyne

    The cause of this process peaking out the cpu at a constant 100% seams to be related to having Boot Camp volumes. Simply dragging the Boot Camp volume to the trash to unmount t makes the process immediately drop down to 0% utilization. Not sure if there is a more permanent way to fix this, there is a way to add exclusions but that involves writing a file to the volume witch is read only. (Or maybe its related to the fact that it used to use the NTFS3G driver for read/write and I changed it back to the OSX native read only driver.)

  • http://www.jacobwcrosby.net Jacob W. Crosby

    Well, being a Mac lover myself, and finding it easy to use the terminal (Due to an abundance of experience with Linux) I have no problems with these occasional bumps along the way. However, for the majority of the ignorant folks on the PC side of things, this sort of stuff is “unacceptable”. How many terminal commands do you have to enter to repair functionality in windows, along with the disk permissions and the disk repair issues? Hell, most windows users do not even know they need to defrag. However, the windows folks would rather deal with a slow, virus laden, severely fragmented computer, because if everything works they don’t care for the most part, even if it has slowed to a crawl. Whereas OS X is rock solid 99% of the time, but when there is a problem, the solution is often a severe pain in the shitter… Though I would happily be inconvenienced for an hour than to be bogged down by needing an antivirus software to scan every single file I open….

    ~Jacob

  • Jeremy Pyne

    Better then the age old “Your gana have to reinstall windows!”.

  • mehmattski

    I had this problem with 10.6.4, driving my fan crazy with mds, and the unix command worked great!

    I would like to add that I had recently installed some (fairly beefy) software from .dmg files that were mounted. When I executed the command, it told me that indexing was now disabled on the dmg drives. So perhaps it’s the indexing of gigantic dmg files that’s eating CPU.

  • FrankR

    To see what Spotlight is actually doing (and what files it might be having problems with, try running this command in the terminal

    sudo fs_usage -w -f filesys mds mdworker | grep “/”

    which means sudo ==> allows command to operate at root – requires admin password fs_usage ==> command that logs what’s happening in the filesystem in real time -w ==> forces a wide, detailed report in terminal -f filesys ==> limits output to file system mds mdworker ==> further limits output to the Spotlight process ‘mds’ and ‘mdsworker’

    | grep “/” ==> passes the output above to the Unix grep which in turn displays only those lines that contain the “/” character – in other words file and directory names.

    (all this based on what I read over at http://superuser.com/questions/46195/why-does-mds-run-wild-in-mac-os-x-10-6/106932#106932

    If you see one file or directory appear over and over again, you can then open the Spotlight preferences panel and exclude it from Spotlight searches. You mav have to reboot to have it take effect.

  • neil

    same problem when i try the command it asks for a password (which i dont have) and wont let me type in that field. how do i get around it

  • neil

    sorry looked up that problem elsewhere and it solved it

  • http://NA Dave

    I’ve run the commands that JS and Frank R gave. Both were supposed to give detailed logs of what was happening while it was happening.

    All I got for the for the first one was :/

    All I for for the second one was an empty rectangular character.

    Why doesn’t Terminal show me what is happening in real time as I dictated by the command???

    My CPU is overloaded more than it ever was now after running these commands and I have no idea what they did or why they made the problem worse.