Controlling photoanalysisd
Tags: mac, macos, photoanalysisd, photos
Published: 2018-08-14 12:01:48

---
title: Controlling photoanalysisd
published: true
description: How to keep photoanalysisd from hogging your CPU
tags: mac, macos, photoanalysisd, photos
---

## Background

I recently bought a new MacBook. This article gets better, I promise.

I decided to set it up fresh instead of restoring from a backup. I like to take the time to try and simplify what I've got on my machine.

Naturally, I expect most applications to take a little bit to sync down settings, files, etc. All of Apple's stuff in particular has a lot to do and I'm fine with that. However, the one I am not so fine with is Photos.

Specifically, a process called `photoanalysisd`. 

This is a background service that, as the name implies, is responsible for analyzing your photos. For the most part, it seems like it is trying to recognize people. This service is directly tied to the "People" tab in Photos (more on this in a moment).

The fact that this happens on your machine and *each* of your machines is a good thing! There may be some things that get sent off to Apple, but the majority of the work seems to be happening on your hardware.

What is not so good is the level of control you have around if/when/how this service is controlled. Or, in this case, how it seems to control your machine.

If you go into the People tab of Photos before it is done analyzing, you will see its progress. Even if you have a fairly beefy machine, this process takes a long time. Weeks kind of long time. The only exception seems to be if you have a photo library barely into or lower than quadruple digits.

On the surface, this shouldn't be an issue. The sorts of analysis its doing is probably computationally intense. It uses a good amount of resources, but doesn't try to fully harness the machine since it is meant to be a background process that occurs over the course of days.

The main issue seems to be that you have no control over this process. I never plan to use the People tab, yet my machine still has to painstakingly go through my entire library. I have a medium size photo library (~10k) and after a few hours on the 12" i5 MacBook, it has managed to go through almost 300 of them. Many people complain about their way more powerful iMacs taking weeks to go through libraries of similar size.

During this process, the machine is still usable, but it doesn't go unnoticed. It does use about 25% of the CPUs constantly. This causes the fanless machine to constantly stay pretty warm and chug on some things. Usually not enough to notice, but seems like it might cause someone to be less than impressed with their *brand new* device if they didn't know this was going on.

On top of that, it is almost impossible for a normal user to learn this is going on. The only mention of "photoanalysisd" is in Activity Monitor. This should not be the only location to learn about something that is using days of CPU time. For a feature I imagine a lot of people either don't want or don't care about having on every device with Photos.

Yet it gets worse.

There are seemingly very few ways to actually get it to stop or even pause. Supposedly, it only runs when a) the machine is plugged in and b) Photos isn't running. This means that people that want it to pause so they can get CPU cycles back resort to running off battery unnecessarily or leaving Photos open for no reason. Even leaving Photos *minimized* makes it start up again. However, mine still runs even with Photos focused, so I guess it doesn't really matter.

You can also just let it finish, but this takes quite a long time (well after their 14 day return policy is up). It also seems like it gets stuck for some people, never finishing.

You can use launchctl to disable and kill the service. However, you have to make sure to disable all the appropriate services, otherwise this is only a temporary reprieve.

Per user Gordan Aspin (https://dev.to/gordonaspin):

```
you do disable it but only in the gui context which is created every time the user logs in and why it keeps be “re-enabled”. Your disable is only for the current GUI login.
```

You also should be able to (re)move the service file, but that may or may not affect system stability. Not something I really want to try, personally. YMMV.

## How to actually do it

To do this, you'll need to open up Terminal and run a couple of commands. Any time you're asked to copy and paste commands into your terminal, it's a good idea to at least have at least a basic understanding of what the commands are actually doing to your system.

The following commands are really 4 command. The `&&` basically means "run the first one (on the left) and if that's successful, run the second one (on the right). `launchctl` is the command that is used to control system services in macOS.

First, you'll disable and kill the GUI instance:

`launchctl disable gui/$UID/com.apple.photoanalysisd && launchctl kill -TERM gui/$UID/com.apple.photoanalysisd`

As well as the actual service:

`launchctl disable user/$UID/com.apple.photoanalysisd && launchctl kill -TERM user/$UID/com.apple.photoanalysisd`

## Closing Thoughts

First off, if anybody from the Photos team somehow ends up reading this, I'm begging you to give us an off switch for the People tab. I don't use it, I don't plan to use it, and it is a huge waste of resources.