Repository navigation
perf(smc): skip absent key probes in long-lived polling - #70
Open
ZongziForu wants to merge 1 commit into
Open
ZongziForu wants to merge 1 commit into
ZongziForu wants to merge 1 commit into
Conversation
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.
Repeated polling currently probes every cross-generation thermal key, including keys absent from the connected Mac. On a MacBookPro17,1, 41 of the 50 temperature keys are absent, so each
status()repeatedly pays for unsuccessfulreadKeyInfocalls.This adds a connection-local firmware key inventory for the long-lived monitor and daemon. A key is skipped only after the entire inventory has been enumerated successfully. Partial/failed enumeration permits all reads and retries later; ordinary value-read failures never mark a sensor missing. App and daemon wake paths invalidate the inventory on their serialized hardware queues.
The existing performance work in #11 addresses polling cadence, successful key-info caching and observation. This PR targets absent-key probes separately and is based on current
main. Default polling intervals, profiles, temperature thresholds and command behavior retain their existing implementation. One-shot CLI callers do not opt into inventory discovery.Validation
swift test: 157 tests passed, including five new inventory tests for different machines, failed/partial enumeration, malformed/duplicate entries and invalidation.swift build -c release: passed.status()reads each after five warm-up reads:This is about a 58% reduction in warm
status()wall time on this machine, not a whole-app CPU claim. The opt-in first read costs about 274–293ms to enumerate the inventory, once per connection or wake. Non-opted-in first reads remained around 12–14ms. Hardware/workload results may differ; other models are covered by inventory tests rather than physical validation.Tools/benchmark-smc-status.swiftincludes build/run instructions; compare its default invocation with--inventory. It performs reads only and never controls fans.