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.
Answered by OneInfiniteLoop in 667743022
[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.
Accepted Answer
[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.
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.

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.

12

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

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.

11

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

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.

See my reply below

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!

Corespotlightd Using Significant CPU In 11.2.2 (20D80)
 
 
Q