Exploring Sierra 10.12.5 sleep and wake in the log, 2 DAS and CTS

I previously worked through the log events which occur when my iMac17,1 goes into system sleep, and wakes from sleep. This article looks at what is reported by the scheduling and dispatching systems, DAS and CTS, during the same events.

Going to sleep

The first reflection of sleep being imminent is shown in messages by CTS, which reports
DarkWake:cpu disk net
suspending activities on transition

The reason that this and other log entries from CTS can be duplicated, is that there are two different instances of UserEventAgent which are originating CTS events, one owned by root, the other by the user. However, DAS log entries are originated by a single process owned by root, DuetHeuristic-BM.

DAS responds to CTS in log entries distinguished by the sub-subsystem com.apple.duetactivityscheduler.powernap:
Entering dark wake
Clearing list of activities that ran
Suspending tasks due to wake state transition

CTS then records
and DAS follows with
Entering sleep
Clearing list of activities that ran
Suspending tasks due to wake state transition

Immediately prior to sleep, CTS sets some tasks pending as Returning IOPMConnection options and sets its timer for Power Nap wake:
Smart Power Nap wake in 11700 sec

DAS and CTS then go silent as system sleep takes effect.

Waking up

One of the earliest markers of the wake-up sequence is CTS, which records (from each of its two instances of UserEventAgent)
DarkWake:cpu disk net
User Active
FullWake:cpu disk net aud vid
resuming activities on transition

DAS then prepares itself to run its scoring system to determine which activities get dispatched:
Entering full wake
Clearing list of activities that ran
Suspending tasks due to wake state transition
Rescoring all 75 activities

DAS next starts to announce its decisions as to which can proceed, and these are passed to CTS to action. CTS also reports
evaluating activities

Interestingly, DAS writes some messages which are typical of those which appear when scheduling by DAS and CTS have broken down due to the current bug in Sierra. DAS refers to triggers, which it also uses when it appears unable to use scores, and writes messages like
Attempting to suspend based on triggers
Ignoring trigger <private> because conditions are deteriorating

At this early stage after waking up, it also seems to cancel or suspend several activities, which is reflected in CTS messages. Eventually, these settle down, and the normal service, of DAS scoring activities and dispatching them to CTS to be run, is resumed.

It is puzzling that DAS and CTS seem able to do this after waking up, but not when Sierra’s bug occurs. One potential workaround for the bug – which disrupts Time Machine backups and many other scheduled activities – may be to allow a brief period of system sleep every five days, perhaps.