Open Activity Monitor and you see mds high cpu mac — sometimes pegging one or more cores at 80–100% for minutes or even hours. The culprit is Spotlight, Apple's system-wide search index. mds (Metadata Server) is the daemon that orchestrates indexing, while mdworker and mdworker_shared are the worker processes that read every file and extract its metadata. On Apple Silicon Macs this usually settles quickly; on older Intel machines — or after a large file operation — it can linger. This guide explains why the spike happens, how to tell when it's safe to leave alone, and what to do when it genuinely gets stuck.
What Are mds and mdworker, Exactly?
macOS Spotlight maintains a private index stored at /private/var/db/Spotlight-V100/ (system volumes) and ~/.Spotlight-V100/ inside some external drives. The index maps every word, attribute, and metadata tag on your disk so that Spotlight, Quick Look previews, Siri suggestions, and third-party apps that use NSMetadataQuery can respond instantly.
mds— the coordinator. It watches the filesystem via FSEvents and schedules work.mdworker— the importer. One or more workers run in parallel, calling content-importer plug-ins for each file type (PDF, DOCX, source code, images, and so on).mdworker_shared— a sandboxed variant introduced in recent macOS releases for processing untrusted file types with tighter restrictions.
None of these are malware. They are signed Apple system processes and cannot safely be killed permanently — macOS will relaunch them.
Why Does the CPU Spike Happen?
Spotlight has to (re)index a file every time its content or metadata changes. The most common triggers:
- macOS upgrade or first boot. Sequoia and Tahoe both refresh the index schema on major updates, forcing a full re-scan.
- Large downloads or copies. Dropping thousands of files into
~/Downloadsqueues them all simultaneously. - Developer build artifacts. Xcode's
~/Library/Developer/Xcode/DerivedDatacan contain hundreds of thousands of object files. Each build adds new files; Spotlight wants to read every one. - Node.js projects.
node_modulesdirectories inside~/Developeror~/Projectsroutinely hold 50,000–200,000 small files — a feast formdworker. - Rust and Maven caches.
~/.cargo/registryand~/.m2/repositoryaccumulate tens of gigabytes of source tarballs and class files over time. - External drives or NAS mounts. Plugging in an unindexed volume starts an index pass from scratch.
- Corrupt or stuck index. Rare, but the index database can become inconsistent, causing
mdsto loop endlessly.
How Long Should You Wait?
On a modern Apple Silicon Mac with an SSD, a normal first-boot Spotlight index typically finishes within 15–45 minutes. On Intel or after a very large file operation, allow up to a few hours. You can check progress in System Settings → Siri & Spotlight → Spotlight Privacy: a progress bar appears below the search field while indexing is active. If CPU stays elevated for more than four hours without any obvious new file activity, you may have a stuck index.
Common Folders That Fuel mds — and Their Sizes
The table below shows typical folder sizes that force heavy Spotlight re-indexing. Excluding them (covered in the next section) stops mds from chasing files you never search by content.
| Folder / Cache | Typical Size | Why Spotlight Loves It |
|---|---|---|
~/Library/Developer/Xcode/DerivedData |
10–60 GB | Hundreds of thousands of object files, each re-written on every build |
node_modules (any project) |
200 MB – 2 GB per project | 50,000–200,000 small JS/TS files per install |
~/.cargo/registry |
2–15 GB | Rust source tarballs and compiled artifacts accumulate across crates |
~/.m2/repository |
1–20 GB | Maven JAR and POM files, one per dependency version |
~/Library/Caches |
2–30 GB | App caches with frequent writes (browser, Xcode, CocoaPods) |
| External drives / NAS volumes | Varies | Indexed from scratch each time they mount |
If you want a broader look at what's eating your disk overall, the guide on what is taking up space on my Mac walks through every major storage category.
How to Exclude Folders from Spotlight (Step-by-Step)
The single most effective fix is telling Spotlight to ignore folders it doesn't need to search.
- Open System Settings (macOS Ventura and later) or System Preferences on older macOS.
- Go to Siri & Spotlight (Ventura+) or Spotlight.
- Click the Privacy tab.
- Click the + button and add the folders you want to exclude. Recommended candidates:
~/Library/Developer/Xcode/DerivedData- Any
node_modulesparent directory, or add individual project roots ~/.cargo~/.m2- Any external drive you use only for backups or media storage
- Click Done. Spotlight immediately removes those paths from the queue — you should see
mdworkerCPU drop within a minute or two.
You can also drag-and-drop folders directly into the Privacy list from Finder.
How to Rebuild a Stuck Spotlight Index
If CPU stays pegged and no progress bar appears, a corrupt index may be the cause. The cleanest solution is to force a full rebuild from Terminal:
- Open Terminal (
/Applications/Utilities/Terminal.app). - Run the following two commands in order. The first turns off indexing; the second turns it back on and triggers a clean rebuild:
sudo mdutil -a -i off sudo mdutil -a -i on - Enter your administrator password when prompted.
- Wait for the new index to complete. Monitor progress in System Settings → Siri & Spotlight.
If you want to target a single volume (for example, your main disk at /) rather than all volumes, replace -a with the volume path: sudo mdutil -i off / then sudo mdutil -i on /.
Erasing the Index Database Manually
In severe cases you can delete the index files themselves before re-enabling indexing:
sudo mdutil -a -i off
sudo rm -rf /.Spotlight-V100
sudo mdutil -a -i on
macOS will recreate the .Spotlight-V100 directory and rebuild from scratch. This is safe — you lose nothing except the index itself, which will be reconstructed.
Permanent Developer Workflow Fixes
Excluding folders helps, but the underlying issue is often accumulation of caches and build artifacts. Cleaning them regularly keeps both disk usage and indexing load low.
- Xcode DerivedData: Delete via Xcode → Settings → Locations → Derived Data → arrow icon, or run
rm -rf ~/Library/Developer/Xcode/DerivedDatain Terminal. Safe to delete at any time; Xcode rebuilds it on the next build. - node_modules: Run
npm cioryarn installto reinstall when needed. See also the guide on cleaning up node_modules on Mac for bulk removal across projects. - Rust crate cache:
cargo cache --autoclean(requires thecargo-cachecrate) or manually prune~/.cargo/registry/cache. - Maven local repo:
mvn dependency:purge-local-repositoryremoves unused artifacts without breaking active projects. - General caches:
~/Library/Cachescontains per-app cache folders. Most are safe to delete when the owning app is closed; the app recreates them on next launch.
A tool like Crumb can audit all of these locations at once and show you exactly what's safe to remove before anything is deleted — useful if you're not sure which caches belong to which apps.
When mds CPU Is a Sign of Something Else
Occasionally, high mds CPU is a symptom rather than the root cause:
- Malware writing files at high speed. If
mdsis spiking continuously for days and you haven't done any large file operations, run a malware scan. - iCloud Drive sync loops. Files stuck in a sync-upload-delete cycle appear as constant new writes to FSEvents, which keeps
mdsbusy. Check~/Library/Mobile Documentsfor unexpected churn. - Time Machine backup in progress. Time Machine prepares snapshots by scanning files; this naturally triggers Spotlight activity on the same files. Wait for the backup to finish.
- Virtualization app disk images. Parallels or VMware disk images stored in an indexed location can cause
mdsto try importing binary blobs. Move disk images to a Spotlight-excluded folder.
In each of these cases, fixing the underlying cause — not just excluding folders — is the right long-term solution.