Skip to content

feat(cpu): CPU-aware power plans#36

Merged
carterscode merged 11 commits into
mainfrom
feat/cpu-aware-power-plans
Jun 5, 2026
Merged

feat(cpu): CPU-aware power plans#36
carterscode merged 11 commits into
mainfrom
feat/cpu-aware-power-plans

Conversation

@carterscode

Copy link
Copy Markdown
Owner

What

CPU-aware power plans: build and apply a Balanced-clone power scheme tuned to the detected CPU's topology, with UI and docs.

Units (U1–U10)

  • U1 scheme-authoring P/Invoke surface (Powrprof)
  • U2 correct Power Saver scheme GUID + base-scheme resolver
  • U3 registry-based CPU detection with a pure parser
  • U4 tiered CPU tune catalog keyed on cache asymmetry (e.g. dual-CCD / X3D)
  • U5 idempotent plan builder + CpuPlanPref config
  • U6 apply integration + in-app docs for cpuplan
  • U7 CPU-aware Recommended preset + dual-CCD debloat guardrail
  • U8/U9 CPU/Power tab + advisory BIOS tab
  • U10 committed reference + wiki

Verification

  • dotnet build clean (warnings = errors)
  • dotnet test — all green (incl. CpuDetector, CpuPlanBuilder, CpuPlanStatus, CpuTuneCatalog, PowerPlanMonitor, RecommendedPreset suites)

Plan + brainstorm included under docs/plans/ and docs/brainstorms/.

🤖 Generated with Claude Code

Add PowerDuplicateScheme, PowerWrite/ReadAC+DCValueIndex, PowerWriteFriendlyName,
PowerDeleteScheme imports plus DuplicateScheme/WriteValue/ReadAcValue/
WriteFriendlyName/DeleteScheme helpers and the processor subgroup + 7 well-known
setting GUIDs. WriteValue writes both AC and DC rails.
…r (U2)

The hardcoded Power Saver GUID was wrong (a1841308-1541-... vs real
a1841308-3541-...), silently breaking Power Saver selection. Add a runtime
base-scheme resolver (GUID match, friendly-name fallback) for the clone base,
honoring the no-hardcoded-scheme-GUIDs rule. Add regression tests.
CpuInfo + CpuDetector: one-time cached registry read of ProcessorNameString/
VendorIdentifier, pure Parse() extracting vendor/normalized-model/family. Regex
keeps the X3D2 dual-edition suffix distinct from X3D. No WMI/CPUID, no new
dependency. Topology/parking is owned by the catalog (U4).
CpuTuneDefinition/Catalog: exact->family->generic resolution, parking strategy
keyed on cache asymmetry (only asymmetric dual-CCD X3D parks the frequency CCD;
single-CCD, symmetric dual, and dual-V-cache 9950X3D2 never park). Seeds the
developer's verified 9850X3D and the 9800X3D single-CCD recipe, 9950X3D dual,
9950X3D2, plus non-X3D Ryzen and Intel-hybrid families and a generic fallback.
All Balanced-based; none use High Performance. Deterministic content hash +
advisory BIOS guidance per entry.
CpuPlanBuilder: pure Decide (Create/ReuseExisting/ReTune) keyed on installed-set
+ machine token + content hash, adopting orphaned GG plans instead of stacking
duplicates and never targeting a foreign machine's plan. MaySafelyDelete
positive-identity guard (installed + GG-named + not Microsoft). BuildOrActivate
re-tunes in place (no delete on the hot path) with partial-failure cleanup.
BestPrebuilt resolver. CpuPlanPref nested under Global (rides existing clone).
CpuPlanApply wraps build-optimized / suggest-prebuilt as one-off DriftItems run
through ChangeApplier; the Apply lambda self-verifies (active==target AND every
override reads back via PowerReadACValueIndex) and throws on mismatch, so a
half-applied plan is reported unverified. Adds cpuplan Mechanism/Apply/Verify
strings, a Learn More catalog entry, and regenerates SETTINGS-REFERENCE.md.
DesiredGuid is pinned only after a successful verify.
…(U7)

The preset's power-plan step is now CPU-aware (recommends the catalog's prebuilt
choice -- Balanced for modern CPUs) and the hardcoded High Performance GUID is
gone. Adds a guardrail so the preset never disables the AMD CCD-routing stack
(V-Cache optimizer / provisioning) or Xbox Game Bar services on an asymmetric
dual-CCD X3D CPU, which would break the optimization.
CPU/Power tab shows the detected CPU + tier/parking, two immediate-apply buttons
(Suggest best prebuilt / Build optimized) guarded by _applyInFlight with
in-progress/error states and DesiredGuid pinned only after a verified apply, plus
a dual-CCD dependency panel (checkable AMD service + Game Bar vs advisory BIOS
CPPC). Advisory-only Recommended BIOS tab keyed to the CPU with an empty-state
card. CpuPlanStatus.DependencyStatus is a pure, tested function that never claims
unqualified 'optimized'.
docs/CPU-AWARE-POWER-PLANS.md and docs/wiki/CPU-Power-Plans.md cover detection,
tiered matching, the cache-asymmetry parking principle, exact recipes and why,
prebuilt-vs-optimized, the dual-CCD dependency stack, the never-touch-built-ins
guarantee, a 'Why not High Performance?' section, and the footprint record.
Adds a Features section to the wiki sidebar.
- Persist CpuPlan identity only AFTER activation + read-back verify (was stamped
  in BuildOrActivate before verify; a verify failure could leave config pointing
  at an unverified plan that the next run trusted via ReuseExisting).
- Orphan adoption now refuses well-known Microsoft plans (a user-renamed built-in
  could otherwise be re-tuned), wiring the positive-identity guard into the
  mutating path.
- Verify both AC and DC rails (writer sets both); add PowerReadDCValueIndex.
- Fix unreachable single-CCD-X3D family catalog entry (now covers unlisted X3D as
  single-CCD no-park); remove dead helper.
- Intel model parse anchors on the i-series prefix so it never grabs a
  frequency/bus number (was fragmenting plan identity for Xeon/Pentium/old Core).
- Make RecommendedPreset's installed-plans set injectable (deterministic test, no
  live OS enumeration).
- Surface unverified result via Any(!Verified); cleaner active-plan-unreadable label.
- Tests: rename misleading NoEntry_RecommendsHighPerformance; add built-in
  delete-guard coverage, null-machine-token reuse, multiple-orphan adoption,
  BestPrebuilt, exact-wins-over-family, unlisted-X3D, older-Intel/Xeon parse,
  ToGuid HighPerf/Ultimate, direct content-hash value-sensitivity,
  not-installed power-plan branch.

@github-advanced-security github-advanced-security AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CodeQL found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.

@carterscode carterscode merged commit 6f24c64 into main Jun 5, 2026
5 checks passed
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