Spotlight taking 200% CPU
Posted by jpluimers on 2021/04/19
First I thought this was about using 4K resolution and chrome, but later I realized that it wasn’t just Chrome disliking high resolutions Spotlight was using a tremendous amount of CPU, not just while Chrome was running:
This was MacOS “mds_stores” high CPU usage all over again, but with different processe names as pointed to me in a sudo su -
shell:
# fs_usage -w -f filesys mdworker | egrep "open" 12:15:58.892425 open F=3 (R_____) /Library/Application Support/Fortinet/FortiClient/conf/epctrl.plist 0.000072 mdworker.5397591 12:15:58.892455 open F=7 (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Local State 0.000129 mdworker.4288698 12:15:58.892974 open F=9 (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/Preferences 0.000098 mdworker.4291263 12:15:58.895614 open [ 2] (R_____) /Library/Application Support/Fortinet/FortiClient/conf/.DS_Store 0.000011 mdworker.5397591 12:15:58.895860 open F=4 (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/History-journal 0.000099 mdworker.5324557 12:15:58.896233 open F=3 (R_____) /Library/Application Support/Fortinet/FortiClient/Logs/epctrl.log 0.000056 mdworker.5446394 12:15:58.896885 open [ 2] (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/.DS_Store 0.000011 mdworker.5324557 12:15:59.142579 open [ 2] (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/.DS_Store 0.000009 mdworker.4291263 12:15:59.394479 open [ 2] (R_____) /Library/Application Support/Fortinet/FortiClient/Logs/.DS_Store 0.000013 mdworker.5446394 12:16:06.892067 open F=9 (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/IndexedDB/https_docs.google.com_0.indexeddb.leveldb/LOG 0.000129 mdworker.4291263 12:16:06.892206 open F=7 (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/IndexedDB/https_docs.google.com_0.indexeddb.leveldb/LOG.old 0.000299 mdworker.4288698 12:16:06.901329 open [ 2] (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/IndexedDB/https_docs.google.com_0.indexeddb.leveldb/Contents>>>>>>>>>>>>>>>>>>>>>>>>>>> 0.000021 mdworker.4291263 12:16:06.902343 open [ 2] (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/IndexedDB/https_docs.google.com_0.indexeddb.leveldb/.DS_Store 0.000008 mdworker.4291263 12:16:07.041993 open [ 2] (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/IndexedDB/https_docs.google.com_0.indexeddb.leveldb/Contents>>>>>>>>>>>>>>>>>>>>>>>>>>> 0.000009 mdworker.4288698 12:16:07.043009 open [ 2] (R_____) /Users/jeroenp/Library/Application Support/Google/Chrome/Default/IndexedDB/https_docs.google.com_0.indexeddb.leveldb/.DS_Store 0.000015 mdworker.4288698 ^C # fs_usage -w -f filesys Spotlight | egrep "open" 12:28:25.042434 open F=23 (R_____) /Users/jeroenp/Library/Caches/com.apple.Spotlight/fsCachedData/BA6E71AE-0786-4535-B6A9-781EA2D36244 0.000048 Spotlight.5497130 12:28:25.051469 open F=23 (R_____) /Users/jeroenp/Library/Caches/com.apple.Spotlight/fsCachedData/48E800C3-7F85-4ED8-AC8C-C8E20C087DF2 0.000050 Spotlight.5497131 12:28:25.062335 open F=23 (R_____) /Users/jeroenp/Library/Caches/com.apple.Spotlight/fsCachedData/605E9CDA-58CE-4024-A193-EA8BE63D0BA4 0.000035 Spotlight.5497159 12:28:25.071471 open F=23 (R_____) /Users/jeroenp/Library/Caches/com.apple.Spotlight/fsCachedData/F93201ED-40C5-4255-8A84-2B6F22D22556 0.000032 Spotlight.5497132 12:28:25.073362 open F=23 (R_____) /Users/jeroenp/Library/Caches/com.apple.Spotlight/fsCachedData/A7BB4DCC-F9C4-4B65-BC1C-80A0D2F9AFAA 0.000022 Spotlight.5497183 12:28:25.172644 open F=23 (R_____) /Users/jeroenp/Library/Caches/com.apple.Spotlight/fsCachedData/AFC8C2B0-1D5E-496E-AF5E-B6D346D06586 0.000042 Spotlight.5497161 12:28:25.224485 open F=23 (R_____) /System/Library/CoreServices/Finder.app/Contents/PkgInfo 0.000037 Spotlight.4189 12:28:25.243310 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/ActiveTileGroup.pbd 0.000065 Spotlight.4189 12:28:25.253612 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/Resources/default-search-3836.styl 0.000010 Spotlight.4189 12:28:25.253906 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/Resources/LocalizationStyleAttributes-4.plist 0.000009 Spotlight.4189 12:28:25.257810 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/Resources/default-icons-478.iconpack 0.000009 Spotlight.4189 12:28:25.260234 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/Resources/default-search-icons-248.iconpack 0.000009 Spotlight.4189 12:28:25.261674 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/RegionalResources 0.000013 Spotlight.4189 12:28:25.269088 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/RegionalResources/18-23-6-pennsylvania-transit-icons-3.iconpack 0.000011 Spotlight.4189 12:28:25.269520 open F=23 (R_____) /Users/jeroenp/Library/Caches/GeoServices/RegionalResources/32-21-6-london-transit-icons-40.iconpack 0.000009 Spotlight.4189 ^C
So after doing a bit more research, I have this in the same shell:
# defaults read /Volumes/Macintosh\ HD/.Spotlight-V100/VolumeConfiguration.plist Exclusions ( "/Library/Caches", "/Users/jeroenp/Library/Application Support/Fortinet/FortiClient", "/Users/jeroenp/Library/Application Support/Google/Chrome/Default/IndexedDB", "/Users/jeroenp/Library/Application Support/Google/Chrome/Default/Local Storage", "/Users/jeroenp/Library/Caches" )
In the Spotlight configuration, this looks far less descriptive:
Fingers crossed this works better now…
Related
The ~/Library
folder: you cannot browse to it directly in finder, but you can “GO” to it from the Finder main menu (Shift-Command-G), then add it as favourite (see [WayBack] How can I remove Library from Spotlight s… – Apple Community).
Keywords (links for commands to man pages at ss64.com/osx/; for system processes, explanation and links to [WayBack] Die Systemprozesse von macOS Sierra | Mac & i):
In case I need these links again to further investigate:
- Slowness / high CPU usage / high energy usage:
- [WayBack] macos – Extreme energy usage by Spotlight – Ask Different
- [WayBack] Spotlight constantly indexes MacBook Air (Lion). Takes up 50+% of cpu – Ask Different
- [WayBack] spotlight – mds and lsd going crazy – Ask Different
- [WayBack] Make Spotlight indexing use less CPU? – Ask Different
- [WayBack] Spotlight’s CPU usage is out of contr… – Apple Community
- Seeing which files are indexed, and where indexing might broke down:
- Tooling and error messages:
- Deleting from
~/Library/Caches
: - (not) indexing folders:
- [WayBack] Three Ways to Prevent Spotlight from Indexing Items on Your Mac
- [WayBack] Prevent spotlight from indexing folders with a certain name – Ask Different
- [WayBack] How do I disable indexing in a specific directory across multiple platforms? (Windows/Linux/MacOS) – Super User
You can exclude a folder from the Spotlight index from System Preferences, by adding
.noindex
to the end of its name, or by creating an empty file named.metadata_never_index
inside it.mdutil -i off
can only be used with volumes (likemdutil -i off /Volumes/volumename/
).To remove existing indexes, you can delete
/Volumes/volumename/.Spotlight-V100/
or runmdutil -E /Volumes/volumename/
. - [WayBack] terminal – How to programatically add folder to Spotlight “do not index”? – Ask Different
You have to stop and start the
launchd
service calledcom.apple.metadata.mds
. So after:sudo defaults write /Volumes/foo/.Spotlight-V100/VolumeConfiguration.plist Exclusions -array-add '/path/to/folder'
do:
sudo launchctl stop com.apple.metadata.mds && sudo launchctl start com.apple.metadata.mds
I replaced the last bit with
sudo bash -c 'echo stop;launchctl stop com.apple.metadata.mds;echo start;launchctl start com.apple.metadata.mds;echo started'
- [WayBack] MacOS Sierra: Enable/Disable Spotlight Indexing
- Enable Indexing –
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
- Disable Indexing –
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist
- Enable Indexing –
- commands:
–jeroen
Leave a Reply