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.

24 Responses to “Is MDS taking over your CPU on OS X? Try Spotless.”

  1. ST Says:

    you really shouldn’t pay for something like this. just learn to use mdutil—it’s only one command to turn indexing on off and another to force re-indexing.

  2. Jeff Mancuso Says:

    ST – how about you save everyone some money and tell us what command to enter! :)

  3. Ryan Says:

    Um.. looks like he did.. the command is mdutil.

    go to /Applications/Utilities/Terminal, start a shell, and type mdutil

  4. Jeff Mancuso Says:

    To clarify – I know about mdutil, but some other people arriving at this post might not feel awesome about rooting through a man page or USAGE printout.

  5. kexofil Says:

    Open a terminal: mdutil -i off

    By just typing mdutil you get some usage information.

    Also, the man-pages are not evil, to survive in a *nix environment you need to learn to read them.

  6. SX Says:

    sudo mdutil -a -v -i off to see that it turned off indexing on connected volumes

  7. Is mds thrashing your OS X? « xentek Says:

    [...] and Textmate is a no brainer, but I didn’t know what or how to address the problem with mds. Come to find out, mds is responsible for indexing in Spotlight. If its thrashing your CPU and hogging up your RAM, [...]

  8. JS Says:

    Erm… for those who are tired of hearing people say “read the man pages” for a Mac, the one simple command to clear out potentially corrupted metadata and rebuild the store from scratch (which is the feature of Spotless being discussed here) is:

    sudo mdutil -avE
    

    That is, sudo (because you have to have admin rights to run this), mdutil (the program that does the work for you) -a for “work on all volumes”, -v for “be verbose in telling me what you’re doing”, and -E for “erase the data store and rebuild it”.

    Honestly guys, why do we have to make every question an opportunity to be superior and arrogant? Yes, mdutil is the command. Did it not occur to you that the question was asking for the specific usage to accomplish this task? So why answer like you didn’t get that? Because you want to show that superior users can read the man pages? Because you feel it’s your responsibility to help people realize that they can’t survive on a Mac without being able to read man pages?

    Come on. This isn’t Slackware. This isn’t Gentoo. This isn’t Solaris. This nix platform is marketed specifically to people who don’t *want to have to RTFM to get by. Give them a break and just answer the questions.

  9. MPf Says:

    Thanks SO much, JS.

    I’m probably a bit more tech savvy than your average Mac user, but without clear guidance like yours, I’d be lost.

  10. Aaron Says:

    @JS: AMEN! There are a lot of little utilities that Apple includes in Mac OS X that aren’t standard *NIX utilities. This just happens to be one of them.

    By the way, this cleared up my 193% CPU usage of MDS under 10.6.

  11. vonspace Says:

    the same here…just installed 10.6 and mds was going 150% cpu usage….now with the sudo mdutil -avE trick works perfectly…thx to all..

  12. socalbiker Says:

    Any idea on why we have to use this unix script to solve a problem that shouldn’t exist? I’ve seen kernel_task equally being driven crazy. This code fixes mds, but what’s really driving this instability in 10.6.1?

  13. socalbiker Says:

    sudo mdutil -avE appears to have solved the problems. That and a disk repair. Apple should have some OS correction that limits this part of the indexing program.

    Can anyone recommend a good book on these support codes?

  14. Chris K Says:

    I had mds at 95% of CPU with 10.6.1. Just did the sudo mdutil -avE command, but a minute later mds was back along with mdworker at 95% combined. What’s up? Did I do something wrong?

  15. bjc Says:

    Is there any way of telling which drive is being indexed by mdutil at any given time?

  16. bjc Says:

    Woooo Whooo… didn’t want to sound like I couldn’t read… so looked at the man page for mdutil and found I could do this:

    mdutil -s -a

    This told me the status of indexing for all of my volumes. Status… simply whether indexing was enabled or disabled. So… I still don’t have my answer.

  17. Steve Says:

    Did you try :

    sudo mdutil -sav

    The v (verbose) may give you a bit more info.

    HTH

  18. joe Says:

    I got tired of the high cpu usage and just turned indexing off. Just as I did on my Windows machines. Google Desktop is actually a worthy substitue and I haven’t had any CPU usage problems with it yet.

  19. SeanG Says:

    This is a great tip. I suddenly started having lots of hard disk usage after setting up a Boot Camp partition (related?), and I’m suspicious now that it’s mds, so I’m rebuilding my indexes.

    I never used to hear anything out of my hard drive on my MBP before the Boot Camp partition was created — now I hear it rattling away all the time! Anyone else experience this?

  20. Michael R. Wolf Says:

    OK for the CPU question. Is there a way to put it on a memory diet? It’s currently taking 500MB real (650MB virtual) memory that could go to better use in Firefox or NeoOffice, the two pigs that I want to feed.

  21. Carlos Says:

    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.

  22. Jeremy Pyne Says:

    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.)

  23. Jacob W. Crosby Says:

    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

  24. Jeremy Pyne Says:

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

Leave a Reply

Subscribe:

Add to Google
RSS
Try ExpanDrive

If you’ve heard of SSH then you need ExpanDrive.