launcher icon indicating copy to clipboard operation
launcher copied to clipboard

Too many idle wakeups

Open directionless opened this issue 2 years ago • 0 comments

This is knowledge and working notes around launcher performance, and energy efficiency. It has been observed that the Activity Monitor launcher process will invariably demonstrate excessive Idle Wake Ups anywhere between 500 and 15000 per second.

Timers/Tickers

Inefficiencies:

Apple recommendation to reduce your app’s energy usage by implementing energy-efficient APIs instead of timers.

launcher has ~1 dozen repeating timers/tickers used to do things like:

  • Monitor the desktop process(es)
  • Fetch control server data
  • Cleanup/purge tasks
  • Log writing
  • Check for launcher/osquery auto-updates
  • Backoff/retry logic
  • Health checks

Remediation:

  1. Create energy efficient ticker for all scheduled tasks with interval > one minute.
  2. Consolidate frequent tickers to a central ticker and/or use OS APIs to provide tolerances in timers, so that they can be executed at the same time as other timers.

Osquery-Go

The code around the Thrift server can be improved

  • Avoid unnecessary os.Stat calls
  • Use an event based API to avoid polling

CGo

directionless avatar Apr 19 '23 18:04 directionless