Repository navigation
Cut idle CPU on battery about 8x without dropping features - #3
Merged
Merged
Conversation
Measured over 5 minutes on battery with the panel closed: the daemon went from 33.3 to 2.95 ms of CPU per minute, the app from 18 to 3.1. - Battery reads take only the 9 keys the daemon and menu bar icon use, instead of copying the whole AppleSmartBattery entry (0.25 vs 1.6 ms when cold). The open panel still reads everything. - The daemon checks every 30 s on battery, where nothing charges, and every 5 s on power as before. Plugging in or unplugging (power source notifications) and config changes (a file watch) trigger a check at once, so settings now apply in ~0.3 s instead of up to 5 s. - Config is parsed again only when the file's mtime or size changed. - An unchanged status is refreshed by touching the file instead of rewriting it (1.6 ms); DaemonStatus.load counts the file's date as updatedAt. - The app polls every 60 s instead of 20 s while the panel is closed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
With the panel closed on battery (the all-day case), Dynamo used ~51 ms of CPU per minute in 1.6; it now uses ~6. No features removed.
proc_pid_rusage)BatteryInfo.read(essentialsOnly:)): 9 keys instead of the whole AppleSmartBattery entry, 0.25 vs 1.6 ms on a cold wakeup. Used by the daemon and by the app while its panel is closed; the open panel still reads everything.utimes);DaemonStatus.loadcounts the file's date asupdatedAt.Checked
./build.sh test: all pass, including a new check that the essentials-only read matches the full read (skipped without a battery, as on CI).updatedAtis 91 s old but the file was touched 25 s ago.