Does your MacBook Pro or Air need a lunchbreak?
Many Mac notebooks lead a busy life. Although they might get a decent sleep, they’re seldom left idle when on mains power. This article looks at some of the tasks that can’t normally be run when a Mac is running on battery power, and may get left undone if it’s too busy when recharging.
Sparse bundles
The only user task among these might catch you by surprise. Sparse bundles (the disk images that store files inside a bundle folder rather than in a single file) may need to be compacted occasionally to ensure they don’t grow larger than they need. Because compaction can take a long time and can’t be interrupted without risking the whole sparse bundle’s contents, by default it won’t be performed when a Mac is running on battery power. That can be overridden in some utilities like my own Spundle, and in the hdiutil command.
Daemons and agents
Although I can’t find them documented anywhere, there are two keys used in the property lists used for LaunchDaemons and LaunchAgents that determine whether their activities and background services will be run when a Mac is running on battery power. AllowBattery is set to true when the service can be run on battery, or to false when it can’t. You will also come across the opposite, RequiresExternalPower, set to true when it can’t be run on battery, or to false when it can. Be careful interpreting their meaning.
Spotlight
Spotlight’s in-app service Core Spotlight consists of many services, some of which aren’t allowed when on battery. Those include:
com.apple.corespotlightd.updateContacts in corespotlightd, which presumably updates information for Contacts’ database;
several parts of com.apple.spotlightknowledged, which is concerned with ‘knowledge’ additions to Spotlight features. These include com.apple.corespotlight.knowledge and its subtasks for inference, journals, and updates;
two parts of com.apple.photoanalysisd, used to analyse media content, in two parts backgroundanalysis and (surprisingly!) music;
several debug services in com.apple.corespotlight.knowledge, which shouldn’t have any user impact.
XProtect Remediator
As we’ve recently realised, regular scans performed by XProtect Remediator (XPR) to detect and remove known malicious software can busy a whole E core for well over half an hour. Because of that, some of its services will only be run when a Mac is powered by mains (AC). There is a ‘fast scan’ that can still take place when on battery, but that doesn’t appear to work through the specialist scanning modules for known malware, and doesn’t record similar entries in the log.
You can observe this yourself after starting your Mac up for the day. If it’s running on mains power and left alone for 10-15 minutes, XPR will usually start scanning with each of its modules. However, if you start your Mac up on battery and leave it for a couple of hours, there’s no sign of those scans starting. This is the result of the AllowBattery key of both com.apple.XProtect.PluginService.agent.scan and com.apple.XProtect.PluginService.agent.slow.scan being set to false in XPR.
Consequences
Most of these services will normally run when a Mac is awake, but not in heavy use. If your Mac spends little time in that state with mains power connected, then they may not be run for many days. When they do get a chance, then you may see long periods during which these services take a significant % CPU in Activity Monitor. If you open its CPU History window on an Apple silicon Mac, you should see them running almost exclusively on the E cores. This ensures that they don’t affect what you’re doing, but they do need the time to do their work uninterrupted, when possible.
For XProtect Remediator, this means that its full scans to detect and remove malicious software won’t take place. While you can run them manually, for example using my free XProCheck, that only runs one set of the two that are normally performed when XPR is run automatically.
Lunch breaks
Many humans take a break at lunch, when they stop their normal work and engage in maintenance. Although some take the opportunity to catch up with their sleep, in most cases folk stay awake.
That’s a model that could allow your MacBook Pro or Air to catch up with some of these background tasks that it needs to have mains power for. Rather than closing its lid to force it to sleep, why not leave it open, awake, running without the load you normally impose on it, and catching up on its Spotlight services and, most important of all, running XProtect Remediator scans? That needn’t necessarily be every day, but a couple of lunch breaks each week could be beneficial for both of you.
I’m grateful to Michele for inspiring this from his own experience.