Skip to content

omarchy-mac: run the CPUs on the performance governor on AC - #33

Open
joshuaswarren wants to merge 2 commits into
omacom:mainfrom
joshuaswarren:feat/cpu-governor-on-ac
Open

joshuaswarren wants to merge 2 commits into
omacom:mainfrom
joshuaswarren:feat/cpu-governor-on-ac

Conversation

@joshuaswarren

@joshuaswarren joshuaswarren commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Ready for review. The AC/battery split (performance on AC, schedutil on battery) is the agreed design; see the opening comment.

What changes

A udev rule runs a small helper when the SMC AC supply (macsmc-ac) appears at boot and on each change of its online value:

  • AC online: every cpufreq/policy* that lists performance gets performance.
  • AC offline: the same policies go back to schedutil, the kernel default.
  • Anything else (no supply, an unknown value, a machine that is not Apple Silicon, a policy that lacks the governor): the helper changes nothing and exits 0.

It adds lib/cpu-governor-policy, vendor/udev/rules.d/95-omarchy-mac-cpu-governor.rules and test/cpu-governor-test.sh. The README, the manual hardware table and version (0.2.3 to 0.2.4) change in the same commit. To keep schedutil on AC, mask the rule with a symlink to /dev/null in /etc/udev/rules.d; the README and the manual say how.

Why

On our lab Macs, schedutil leaves the CPU near its low clock while the GPU or the Neural Engine runs a job. Inference that waits on the CPU then runs slower. A/B runs on the same kernel and the same model, schedutil as found against performance:

Mac Model schedutil performance Ratio
13" M1 gemma 4 E4B 10.65 tok/s 15.27 tok/s 1.43x
16" M1 Max 26B model 10.40 tok/s 12.80 tok/s 1.23x

Each row is one lab series; the measured receipt for the 13-inch row is in the opening comment.

Tested

  • test/all passes (exit 0). The new test covers AC online and offline, an unknown value, a missing supply, a policy without the governor, and a non-Apple machine, all against a fixture sysfs.
  • The mac-manual builds (14 pages).
  • On a 16" M1 Max on AC with the Aurora 12.6 kernel: a runtime-only udev rule with the same match ran for ACTION=change and ACTION=add on macsmc-ac, with POWER_SUPPLY_ONLINE=1. The helper wrote performance, which was already set. CONFIG_ARM_APPLE_SOC_CPUFREQ=y there, so the policies exist when udev coldplug runs.

Not tested

  • The battery side on hardware. I did not unplug a Mac. Battery draw and thermals under performance are not measured. Nothing here claims the battery side is cheap.
  • A real boot with the packaged rule in /usr/lib/udev/rules.d. The cold-boot path rests on the coldplug add event, which I ran by hand.
  • A MacBook Air that charges through USB-C. I did not check that macsmc-ac reports online there.
  • Interaction with power-profiles-daemon. On one Mac the daemon runs with the balanced and power-saver profiles and a placeholder driver that does not touch cpufreq, so it does not conflict. A profile change does not change the governor.

Main is at 0.2.3 after omarchy-mac-pkgs#32, so this bumps to 0.2.4.
@joshuaswarren

Copy link
Copy Markdown
Contributor Author

Opening for review.

This draft waited on one design question: whether the AC/battery split should be the shipped default. It is settled. In the Omarchy M+ team chat on 2026-10-11 the answer was full power when plugged in and low power on battery, and the lab Macs have run performance as their default since the same day. This PR implements exactly that, so it no longer needs to sit as a draft.

The measurement behind the 13-inch row above (series of 2026-10-11, same boot and model, ANE idle, control spread 0.3 percent): gemma-4-E4B decode on a 13-inch M1 MacBook Pro read 10.65 tok/s under schedutil and 15.27 tok/s under performance (1.43x).

Checks at this head (b032099):

  • CI green: build, Shellcheck, scope and architecture gates, aarch64 package sets, package/integration/tooling suites.
  • Fresh local run of omarchy-mac/test/cpu-governor-test.sh: all six assertions pass.
  • The limits stay as listed under "Not tested": the offline path is covered by the mocked-supply test only; no battery-draw numbers exist yet.

@maralcbr ready for your review whenever it fits.

@joshuaswarren
joshuaswarren marked this pull request as ready for review November 4, 2026 21:47
@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The change affects CPU governor selection on Apple Silicon Macs using this package.

The PR appears safe to merge, with a non-blocking correction needed in the opt-out instructions.

Findings

  1. P2 Opt-out leaves performance enabled ▶

Summary

Adds automatic CPU governor changes on Apple Silicon: performance on AC and schedutil on battery.

  • Mac CPUs switch governors when the charger changes.

Acknowledged limits from joshuaswarren: the packaged cold-boot path, battery hardware, USB-C charging, battery draw, and interaction with power-profiles-daemon remain untested. The AC/battery split is intentional.

Reviews (1) · Last reviewed commit: "Merge origin/main into feat/cpu-governor..." · Reviewed by Greptile

Comment thread omarchy-mac/README.md

On AC the CPUs run the `performance` governor, and on battery they run `schedutil`, the kernel's default. The package's udev rule runs `/usr/lib/omarchy-mac/cpu-governor-policy` when the SMC AC supply (`macsmc-ac`) appears at boot and on each change of its `online` value. The helper sets every `cpufreq/policy*` that lists the governor, on Apple Silicon only, and otherwise leaves the governors alone. Nothing needs enabling.

`schedutil` can leave the CPU near its low clock while a GPU or Neural Engine job runs, which slows inference that waits on the CPU (measured numbers are in the pull request). Battery draw under `performance` is not measured. To keep `schedutil` on AC too, mask the rule: `sudo ln -s /dev/null /etc/udev/rules.d/95-omarchy-mac-cpu-governor.rules`. Anything that sets a governor by hand is overwritten at the next AC event.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Opt-out leaves performance enabled

Masking the rule does not restore schedutil if the helper has already selected performance. It also stops the unplug event from restoring it, so someone following this opt-out can stay on performance on battery until reboot. Tell users to reboot after masking, or include a command that restores schedutil immediately. The manual needs the same clarification.

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