Background activity scheduling with CTS in Catalina

Over the last week, I’ve been looking at how macOS now runs background ‘activities’ using Centralized Task Scheduling (CTS). To round this off, this article outlines what happens in macOS Catalina 10.15.7, in particular listing the services which are now scheduled and dispatched by CTS. In summary, these include the following:

  • Calendar – syncing, iCal service and subscriptions
  • Contacts – syncing
  • Differential Privacy
  • eficheck – weekly firmware check
  • Find My services
  • iCloud – bird service, CloudKit
  • Maps – announcements
  • Messages – syncing
  • Periodic maintenance – daily, weekly, monthly housekeeping
  • Photos – analysis and library maintenance
  • QuickLook – maintenance of thumbnails
  • Security – signature revocations, KEXT deprecations
  • Software Update – routine checks for security and other updates
  • Spotlight indexing – maintenance
  • Suggestions – updates
  • Time – periodic time recalibration using NTP
  • Time Machine – automatic backups.

Full lists are given in the appendix.

Once CTS and DAS have initialised after Catalina has started up, they proceed to check in their many activities, initially with CTS. This seems to be the result of their being loaded via LaunchAgents and LaunchDemons. These are marked by log entries such as
xpc_activity_register:, criteria: check-in

Once the user has logged in, these proceed with user activities as well as those run as root. Later, CTS starts submitting these to DAS for entry into its managed lists. These are shown in log messages which contain details of the schedule dictionary, such as
Submitting DASActivity: <dictionary: 0x7fc81020a3b0> { count = 7, transaction: 0, voucher = 0x0, contents =
"Repeating" => <bool: 0x7fff967b2490>: true
"Interval" => <int64: 0xa133add99d3f401f>: 259200
"RequireScreenSleep" => <bool: 0x7fff967b2490>: true
"GracePeriod" => <int64: 0xa133add9b76f401f>: 86400
"RequireBatteryLevel" => <int64: 0xa133add9a273201f>: 70
"AllowBattery" => <bool: 0x7fff967b2490>: true
"Priority" => <string: 0x7fc81020a450> { length = 11, contents = "Maintenance" }

If you want to inspect the schedule settings for any activity, these are the best place to look.

Eventually, DAS runs up with messages such as
Low Likelihood is from (null) to (null)
Using restart times of <private>
Creating shared memory for budgeting (likely after reboot)
SystemStats: Initializing budget manager

Log entries following that provide insight into the data structures which DAS uses, and you’ll also see it refer to activity lists, groups of activities which are scheduled to run together in a coordinated manner. DAS soon gets on with evaluating individual activities in its exchanges with CTS. A simple example is
Submitted Activity: at priority 30 with interval 3600 <private>
Activity <private>: Optimal Score 0.8451 at <private> (Valid Until: <private>)

Longer examples give insight into the many factors which DAS takes into account when dispatching activities for CTS. Those include thermal and memory pressure, as well as time. There’s a great deal to explore in the log excerpts provided by Mints which provides better insight into these sophisticated scheduling systems.

Appendix: Main activities scheduled by CTS in Catalina 10.15.7

1. Run as root (two) Time Machine automated backups, every hour Time Machine, every day (multiple) DAS (daily) DAS (daily) (multiple tasks) eficheck firmware check, every week (multiple tasks) Fixup (multiple tasks) check (2) (multiple tasks) (multiple tasks) (multiple tasks) every 6 hours daily housekeeping monthly housekeeping weekly housekeeping every 6 hours (two)

2. Run as user Contacts sync over iCloud, hourly (three) iCloud, six three iCloud, six three two, one for CalDAVPrincipal, the other for SubscriptionInfo three two two four two two nine three