My Mac had been dragging for a day or so. First suspect was Colima, since it’s usually the thing quietly hogging my CPU. This time it wasn’t.
The Setup
Colima checked out clean, 2 CPUs, 2GiB RAM, VM process sitting under 1% CPU. So
I ran ps aux and found the real offender straight away.
USER PID %CPU %MEM COMMAND
eric 86198 129.7 8.9 mediaanalysisd
mediaanalysisd is the built-in macOS daemon that handles face recognition, scene
detection, and search indexing for Photos. It had been sitting at 130% CPU and
3GB of RAM since 5:07pm the day before.
Chasing the Wrong Lead
I assumed Photos, maybe an iCloud sync had kicked off a re-index. lsof backed
that up at first, it had Photos.sqlite and MediaAnalysis.sqlite open under
~/Pictures/Photos Library.photoslibrary.
Except that database had zero assets in it.
❯ sqlite3 "Photos Library.photoslibrary/database/Photos.sqlite" \
"select count(*) from ZASSET;"
0
There was an iCloud sync status file claiming 197 photos, so maybe those just hadn’t downloaded yet. But I don’t use iCloud for photos… Let’s dig deeper.
Sampling the Process
When ps and lsof run out of answers, sample is the next step, it grabs a
process’s call stack over a short window so you can see what it’s actually doing
on the CPU.
❯ sample 86198 1 -mayDie -f /tmp/sample.txt
-[VCPMovieAnalyzer analyzeAsset:streamed:]
-[VCPAudioAnalyzer analyzeAsset:cancel:results:]
-[VCPAudioAnalyzer processSampleBuffer:]
-[VCPAudioClassifier processAudioSamples:timestamp:]
SoundAnalysis framework
It was the audio classification, which Apple uses to tag video with sound categories (music, speech, applause) for Siri Suggestions and Spotlight search. And it had been stuck in that exact stack for over 17 hours straight.
lsof again, this time looking at the actual open files, cleared things up.
mediaanal 86198 eric 34r .../Downloads/movie-1.mp4
mediaanal 86198 eric 37r .../Movies/movie-2.mp4
mediaanal 86198 eric 38r .../Movies/movie-3.mp4
mediaanal 86198 eric 39r .../Movies/movie-4.mp4
mediaanal 86198 eric 42r .../Movies/movie-5.mp4
mediaanal 86198 eric 43r .../Movies/movie-6.mp4
mediaanal 86198 eric 44r .../Downloads/movie-7.mp4
mediaanal 86198 eric 45r .../Downloads/movie-8.mp4
Eight full 1080p movies, all with 5.1 audio, all open at once. Spotlight had been running sound classification across my entire movie collection and gotten stuck somewhere in the middle of it.
The Fix
❯ kill -9 86198
CPU dropped immediately. To stop it happening again I excluded my movie folders
from Spotlight entirely, System Settings > Siri & Spotlight > Spotlight Privacy,
added ~/Downloads and ~/Media/Movies.
Takeaway
mediaanalysisd isn’t just a Photos thing. It reaches into Downloads, Desktop,
wherever it can find media, and runs audio classification on video files too. If
your Mac slows down and Activity Monitor points at it, sample the process and
check what files it actually has open, then exclude them from Spotlight.