daemon-activity

command
v0.6.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

daemon-activity

daemon-activity demonstrates github.com/tmc/apple/x/daemon with zero cgo (CGO_ENABLED=0):

  • Queries SMAppService registration state via daemon.ServiceStatus()
  • Acquires a latency-critical daemon.Guard combining an NSProcessInfo activity (UserInitiated | LatencyCritical | IdleSystemSleepDisabled | AutomaticTerminationDisabled) and an IOKit PreventUserIdleSystemSleep power assertion (IOPMAssertionCreateWithName)
  • Proves the IOPMAssertionID is live in macOS power management via pmset -g assertions
  • Measures high-frequency timer wake jitter (min/p50/p95/p99/max) under AcquireLatencyCritical
  • Releases the guard via Close() and verifies the assertion disappears from pmset -g assertions

Run

CGO_ENABLED=0 go run ./examples/os/daemon-activity

Flags:

  • -reason: assertion and activity reason string (default daemon-activity latency-critical worker)
  • -samples: number of timer wake samples (default 200)
  • -period: target timer wake period (default 2ms)

Measured Output

Captured on this Mac with CGO_ENABLED=0 go run ./examples/os/daemon-activity:

== Service Status ==
  pid            : 50177
  service status : not-found

== Acquire Latency-Critical Guard ==
  assertion kind : PreventUserIdleSystemSleep
  assertion id   : 41568 (0xa260)
  activity opts  : 0xff00ffffff
  reason         : daemon-activity latency-critical worker (pid=50177)

== pmset Verification (Active) ==
  pmset live     : yes
  pmset entry    : pid 50177(daemon-activity): [0x0003cbb80001a260] 00:00:00 PreventUserIdleSystemSleep named: "daemon-activity latency-critical worker (pid=50177)"

== High-Frequency Timer Wake Jitter (200 ticks @ 2ms) ==
  samples        : 200
  period         : 2ms
  min            : 0.4 us
  p50            : 1.1 us
  p95            : 1.8 us
  p99            : 10.5 us
  max            : 236.4 us

== Release & pmset Verification (After Close) ==
  guard closed   : yes
  pmset live     : no (assertion 41568 released)

Documentation

Rendered for darwin/amd64

Overview

Command daemon-activity demonstrates github.com/tmc/apple/x/daemon.

It queries SMAppService status, acquires a latency-critical daemon.Guard (NSProcessInfo activity + IOKit PreventUserIdleSystemSleep assertion), verifies the live IOPMAssertionID in "pmset -g assertions", measures high-frequency timer wake jitter (p50/p95/p99) while guarded, releases the guard, and confirms the assertion disappears from pmset.

Run directly:

CGO_ENABLED=0 go run ./examples/os/daemon-activity

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL