Corespotlightd Using Significant CPU In 11.2.2 (20D80)

Hello!

I am wondering if anyone else is experiencing a significant CPU drain from Spotlight (specifically corespotlightd) in macOS 11.2.2.

Since updating to macOS 11.2.2 any time that I access spotlight using Command + Space Bar I immediately experience a system wide lag. Viewing this in Activity Monitor I see a %CPU spike of corespotlightd in the realm of 200-400%. that last for anywhere from 5 to 15 seconds.

I have sent this in through Feedback Assistant, but no other reports seem to have been linked to the radar.

I have attempted a few different fixes as well:
  • Terminal killall corespotlightd resolves the issue momentarily, but does not fix long term

  • Restarting computer does nothing to solve

  • Re-indexing spotlight does not solve

  • I have also disabled more advanced search functions (Bookmarks and History, Contacts, Events and Reminders, Fonts, Mail & Messages, Music, Siri Suggestions, and Movies are all disabled) - This did not fix the issue.

  • I have also disabled search for external hard drives which also did not solve the issue.

Open to any other suggestions for fixes, or if anyone else has a similar issue.

Mac mini, 2018 (2020 release), 3.2 GHz 6-Core Intel Core i7, 32 GB 2667 MHz DDR4. External GPU Radeon RX 570 4 GB.
  • See my reply below

Add a Comment

Accepted Reply

[UPDATE]

So after significant troubleshooting including:
  • Reindex via terminal

  • PRAM/NVRAM reset

  • SMC reset

  • Hardware test

  • Confirming that the issue occurs in safe boot

  • Reinstall macOS Big Sur via Recovery Mode

I finally gave up and fixed with the following:
  • Boot into Recovery Mode

  • Wipe the SSD via Disk Utility

  • Reinstall macOS Big Sur through Recovery Mode

  • Confirm the issue doesn't occur on a clean install (it didn't - issue was fixed)

  • Restore ONLY apps and documents with Migration Assistant

Issue now resolved.
  • (deleted, posted as answer for better formatting)

  • Although I'm thankful for your post about how you fixed it, I consider that being completely defeated, rather than fixing it. I couldn't possibly handle the disruption of removing the vast majority of apps and settings.

Add a Comment

Replies

[UPDATE]

So after significant troubleshooting including:
  • Reindex via terminal

  • PRAM/NVRAM reset

  • SMC reset

  • Hardware test

  • Confirming that the issue occurs in safe boot

  • Reinstall macOS Big Sur via Recovery Mode

I finally gave up and fixed with the following:
  • Boot into Recovery Mode

  • Wipe the SSD via Disk Utility

  • Reinstall macOS Big Sur through Recovery Mode

  • Confirm the issue doesn't occur on a clean install (it didn't - issue was fixed)

  • Restore ONLY apps and documents with Migration Assistant

Issue now resolved.
  • (deleted, posted as answer for better formatting)

  • Although I'm thankful for your post about how you fixed it, I consider that being completely defeated, rather than fixing it. I couldn't possibly handle the disruption of removing the vast majority of apps and settings.

Add a Comment
I have this issue - it's so annoying - search is always broken in Mail and I can temporarily fix it by force killing corespotlightd, but it doesn't last. On 11.2.3 here. Please Apple, fix this!
I don't think a fresh install is an acceptable fix
I don’t disagree with you, sadly I did not find a better fix and this was a huge pain for the way I work so it was a worthwhile choice.

For anyone who'd like a less drastic solution (ro reformatting your drive and a fresh reinstall) there's the option to script force quitting it every second or so.

Still not what I'd call an "acceptable" solution, but an option some might consider nonetheless.

Add the following towards the end of your .bashrc or .bash_profile:

stopcorespotlightd() {
    while true; do
        sleep 1
        if pgrep -x "corespotlightd" > /dev/null; then
              killall -ABRT corespotlightd
        fi
    done
}
stopcorespotlightd > /dev/null &

(...or adapt for zsh or other shell choice as you see fit).

Disclaimer:

If you don't know what you're doing in Terminal and bash scripting please don't use this.

To my knowledge corespotlightd can not be gracefully quit so the above is force quitting it every second. Force quitting anything is only ever advised as a last resort. Arguably this is such a scenario, short of reformatting your drive per the accepted answer.

I have run this successfully for a few weeks, without any noticeable issues, and it has saved me loads of CPU, RAM and SSD thrashing. I believe very confidently it will not do your Mac any harm, but I offer no guarantees and do not accept any responsibility for your use of it or any adaptation of it.

  • WHOAAAA *PLEASE DO NOT DO THIS!! SO INNEFICIENT and harmful: **1. Only interferes with a process, not stops 2. Recursively runs a forced cmd (this practice alone is just a no-no in code unless youre trying to unplug a hack 3. It runs, yet never stops other activty - just replaces spotlight with another process 4. Forcing a command simply hurts cpus. This is why it's buried in Terminal wastelands. Every time you forcequit process, tiny circuits fry. Literally. Like using sudo purge always BADD

  • EDIT ABOVE: In summary, avoid ever running recursively forced task, period. Devs add 'retry' limits of ~5 by default. Never have lingering code that can both access and runs any sudo task every single second. I ask you not to post code prior to considering its risk, testing it, and receiving feedback. I'm very adamant about reacting with clearly negative emotion on these types of issues so that any Machine Learning model crawling code snips can anchor my sentiment to its suggestion score. FYI!

Add a Comment

I battled this for months but, dreading a full reinstall and (selective) restore, resorted to trying many things, including the steps suggested by OneInfiniteLoop above. Nothing worked. Spotlight and corespotlightd were consistently at 350% CPU, for many seconds, sometimes up to what felt like a minute. Logs were inconclusive (to me at least).

What finally worked for me was to:

  1. Turn indexing off: mdutil -a -i off /
  2. Trash all spotlight data: rm -rf ~/Library/Metadata/CoreSpotlight/ and sudo /System/Volums/Data/.Spotlight-V100, then
  3. killall -KILL Spotlight spotlightd mds (not sure this was the right set of processes)
  4. Turn indexing back on: mdutil -a -i on /

For some reason I had to do this twice. Probably because I was too lazy to restart.

Note: the recommended way of excluding and then including your SSD again to force a spotlight reindex did not work.

Anyway, now everything is back to normal, spotlight—and Mail.app search, Notes.app search, etc., including Time Machine backups (!!, go figure)—are blazingly fast and never exceed 30% CPU.

Problem solved—for me and for now at least… Hope this helps.

  • This worked for me. Thanks coinspiranted!

  • After correcting the little mistakes in your command lines, this worked for me as well ! Thank you coinspiranted !

  • Worked for me as well (at least going on a few hours now). Thanks for this!

Anicek, can you repost with the mistakes fixed? I could not get this to work. Also, do you need to log in as root?

  • Late reply but posting for archive, you can run commands as root by adding 'sudo -i' before the command

Add a Comment

coinspiranted post above worked for me but with a couple caveats...

In macOS Big Sur the spotlight data folders are protected by SIP, and so Terminal needs to be granted "Full Disk Access" per this StackOverflow post:

https://unix.stackexchange.com/questions/507063/cant-list-directory-even-as-root

I believe that it is macOS's SIP (System Integrity Protection) that stops the du and lsprocesses from accessing the files/directories, even when running as root. SIP appears to be, since macOS Mojave, active for a number of locations under ~/Library, which means that only trusted applications can access them.

I added my terminal application (iTerm2) to the list of applications that should be granted "Full Disk Access", and I did that in the "Security & Privacy" Systems Preferences settings, under the "Privacy" tab. This seems to have solved it for me. I say "seems" as I'm no macOS expert, but I believe this is what made me able to access everything under ~/Library.

Apple recommends not turning off SIP globally on the system, for obvious reasons, and I don't see a real reason to do so either.

After you have followed the instructions above then

sudo mdutil -a -i off /

sudo killall -KILL Spotlight spotlightd mds

sudo rm -rf ~/Library/Metadata/CoreSpotlight/

sudo rm -Rf /System/Volums/Data/.Spotlight-V100

Then restart, you should be good to go!

You can optionally then disable "Full Disk Access" for Terminal at this point if you are concerned about security.

  • I see your post misses turning mdutil back on, is this intentional?

  • This seemed to work for me. I also reenabled indexing. I know of at least one other who said it did not solve their problem so there maybe a couple of issues rolling around causing the problem.

  • This was the best solution for me. Don't forget to turn on mdutil at the end with sudo mdutil -a -i on /, and it took few hours for spotlight index to rebuild. Also removed Terminal.app from Full Disk Access.

    Now 24hrs later, spotlight is calm, CPU usage is normal, fans not preparing for takeoff anymore.

Easiest Way I found to do this.

Open Spotlight Control Panel Click on Privacy Drag each of your disks over to privacy, Click Yes you want to disable that disk search Wait for spotlight to clean up indexes on all the disks Drag the disks out of Privacy, or if you dont use spotlight then just leave them Spotlight will reindex everything once the disks are removed from Privacy

  • I'd like to try this solution (not familiar with terminal). How can I see whether Spotlight has finished cleaning up indexes? Or how long should I wait?

Add a Comment

Hey, this has been happening to me, and makes my MacBook nearly overheat if I don't notice it. The easiest and most convenient approach to solving this was to just go to the Activity Monitor, double click spotlightd, and Force Quit it.

Haven't tried it recently, but last year, I created a new separate account on my MBP and moved all of my work and mail over to it. Mail was a pain to move, but it seemed to solve a lot of problems at the time.

Having too many email accounts in Mail seems to be a part of the problem, especially if they were Office365 emails. Disabling some of the emails in Preferences calmed things down, but I need them for work, so not sure what to do. Funneling several email accounts into one helped, but did not fix the problem.

The following worked for me on macOS Ventura when the other suggested solutions did not.

sudo -i
mdutil -Ea
mdutil -ai off
mdutil -ai on

Note: A good way to check if Spotlight is healthy is to see the Indexing status when doing a search. If you are not seeing this indication then there is a problem with Spotlight.

  • Thank you, mta59066, you saved me. Fast, simple, and clean. Had no idea I should see the indexing status. Appreciate you.

Add a Comment

Here are the complete steps outlined by @sgbett, but with missing parts filled in:

  1. Grant Terminal app Full Disk Access in Settings
  2. In Terminal app, run the following commands, which will turn Spotlight off, kill running Spotlight processes, and remove Spotlight's existing data.
sudo mdutil -a -i off /
sudo killall -KILL Spotlight spotlightd mds
sudo rm -rf ~/Library/Metadata/CoreSpotlight/
sudo rm -Rf /System/Volums/Data/.Spotlight-V100``

  1. Reboot your machine
  2. In Terminal, run the following command to turn spotlight back on:
Sudo mdutil -a -i on /

  1. Disable "Full Disk Access" in Settings for Terminal app (unless you have reason to keep it that way)

Just as a note, the last post as outlined by @mrdjasonm will delete most of the files on your Mac and will not have a way to recover them unless you have a backup - not sure what got lost in translation here but that will delete a lot more than the Spotlight metadata as outlined by @sgbett -use the internets with caution!

  • the command mentioned only deletes Spolight's directories, I am not sure how that would delete our personal files, am I missing something?

Add a Comment

@RHarry is right – this solution from @mrjasonm will delete your files! I am currently cursing and trying to run file recovery.