feat: smctl power status — 热压制 / CPU 降频 / 功耗可见性#1
Merged
Conversation
Read-only power/thermal picture, no root and no daemon (mirrors `sensors`): - Thermal pressure from ProcessInfo.thermalState (system's own assessment). - CPU throttling from `pmset -g therm` — Apple Silicon returns kIOReturnNotFound for IOPMCopyCPUPowerStatus (verified on M4 mini), so pmset is the only public non-root source for the actual speed-limit %. "No status recorded" means not throttled, not unknown. - Package power (PDTR) and input power (VD0R x ID0R) from SMC. PmsetThermParser is a pure, fixture-tested function; PowerReader injects all three sources for deterministic unit tests.
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.
做了什么
新增
smctl power status—— 把「被压制没有 / 压了多少 / 吃多少电」拼到一屏。纯只读,不要 root、不要 daemon(与sensors同类,daemon 没装也能用)。支持
--json和--watch。数据源(三层)
ProcessInfo.thermalStatepmset -g thermIOPMCopyCPUPowerStatus在 Apple Silicon 返回 kIOReturnNotFound(M4 mini 验证),pmset 是唯一公开、非 root 的限速百分比来源PDTR/VD0R×ID0R关键语义:pmset 报 "No CPU power status has been recorded" = 未降频,不是 unknown。
测试
PmsetThermParser抽成纯函数,针对空闲 / 降频 / 异常间距等 fixture 单测。PowerReader注入三路数据源,确定性单测,不 fork 子进程。落地背景
这是「电源管理」线的第一步(只读)。电源策略写入(低功耗模式等)待实测 M4 mini 可控旋钮后再上;降频数据后续可接入温度/事件告警作为触发源。