Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SMAppService if macOS >= 13 and improve performance slightly #80

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

uthiel
Copy link

@uthiel uthiel commented Oct 19, 2023

  • With macOS 13, Apple introduced a drastically simplified way of launching an app at login, SMAppService. This PR encapsulates the new API into an availability check in order to preserve downward compatibility.

  • thermal stats are currently read by executing /usr/bin/pmset and parsing the result, which is inefficient and fragile. This PR calls IOPMCopyCPUPowerStatus directly just like pmset does which mainly results in more stable code but also a ~3% performance gain on x86_64 or ~6% on arm64e.

@uthiel uthiel changed the title Use SMAppService if macOS >= 13 Use SMAppService if macOS >= 13 and improve performance slightly Oct 23, 2023
@varenc
Copy link

varenc commented Dec 10, 2023

  • thermal stats are currently read by executing /usr/bin/pmset and parsing the result, which is inefficient and fragile. This PR calls IOPMCopyCPUPowerStatus directly just like pmset does which mainly results in more stable code but also a ~3% performance gain on x86_64 or ~6% on arm64e.

I love transitioning to this! Just started using Hot and discovered it's spending all its time running pmset -g therm and looking at the results... checked out the github to see any discussion on this and was delighted to discover this PR!

Though also, on the new Apple Silicon computers I'm not sure if pmset -g therm or the IOPMCopyCPUPowerStatus equivalent even provides any useful information anymore? pmset -g therm seems to always just return this on my M3 MBP even when I know it's thermal throttling:

Note: No thermal warning level has been recorded
Note: No performance warning level has been recorded
Note: No CPU power status has been recorded

and the pmset man page notes that thermal information is "not available on all platforms".

So it's unclear to me if this code even needs to be ran on Apple Silicon machines at all.

@uthiel
Copy link
Author

uthiel commented Dec 14, 2023

So it's unclear to me if this code even needs to be ran on Apple Silicon machines at all.

It doesn't. That's why the last commit executes it only on x86.

Repository owner deleted a comment from uthiel Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants