From b3cf0c6f29cf8a5473fa1b8a8a446ebb41b2e5de Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Tue, 28 Jul 2026 08:24:13 -0700 Subject: [PATCH] Run the live CPUs at the performance governor during install (#89) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit archiso boots on whatever governor the kernel defaults to, which on most laptops ramps conservatively. Package extraction and the UKI build are both CPU-bound, so pin performance for the whole install and put it back afterwards. Reduced from #87 by @davydotcom, which also disabled every non-POLL cpuidle state. That half is left out deliberately: C1 wake latency is 1us on current hardware, and disabling it leaves POLL as the only idle state, so idle cores busy-spin instead of halting. Package extraction is single-threaded, so on an 8-core laptop that is 7 cores burning power for no work — on a thermally limited machine that costs the working core its turbo headroom, which is a plausible way to make the install slower. #87 measured the two tweaks together with a page-cache prefetch and an updatedb deferral, so the C-state contribution was never isolated. Scoped to the whole install rather than just the pacstrap window, which #87 used: finalize_limine_boot runs mkinitcpio and compresses a UKI, and is the most purely CPU-bound phase there is. Restoring only matters when an install fails and the user keeps using the live environment; a successful one reboots out of it. Co-authored-by: David Estes Co-authored-by: Claude Opus 5 (1M context) --- .../share/omarchy-iso/orchestrator/main.py | 5 +++ .../omarchy-iso/orchestrator/phases_impl.py | 34 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/configs/airootfs/usr/share/omarchy-iso/orchestrator/main.py b/configs/airootfs/usr/share/omarchy-iso/orchestrator/main.py index 46142e0..62f4c88 100644 --- a/configs/airootfs/usr/share/omarchy-iso/orchestrator/main.py +++ b/configs/airootfs/usr/share/omarchy-iso/orchestrator/main.py @@ -65,11 +65,15 @@ def main() -> int: info(f"Installing Omarchy for {ctx.username} → {ctx.target}") from .phases_impl import ( + boost_cpu_governor, cleanup_bind_mounts, cleanup_protected_state, cleanup_target_hook_masks, + restore_cpu_governors, ) + governors = boost_cpu_governor() + success = False try: try: @@ -85,6 +89,7 @@ def main() -> int: info("Installation complete.") return 0 finally: + restore_cpu_governors(governors) cleanup_bind_mounts(ctx) cleanup_target_hook_masks(ctx) if not success: diff --git a/configs/airootfs/usr/share/omarchy-iso/orchestrator/phases_impl.py b/configs/airootfs/usr/share/omarchy-iso/orchestrator/phases_impl.py index fdc66c9..80c7b77 100644 --- a/configs/airootfs/usr/share/omarchy-iso/orchestrator/phases_impl.py +++ b/configs/airootfs/usr/share/omarchy-iso/orchestrator/phases_impl.py @@ -1396,6 +1396,40 @@ def _validate_pre_mounted_filesystems(ctx: InstallContext) -> None: raise RuntimeError(f"{crypttab} missing LUKS UUID {storage['luks_uuid']}") +CPU_SYSFS = Path("/sys/devices/system/cpu") + + +def boost_cpu_governor() -> dict[Path, str]: + """Run the live CPUs flat out for the install. + + Package extraction and the UKI build are both CPU-bound, and archiso boots + on whatever governor the kernel defaults to. Writing an unsupported + governor just fails, so nothing needs probing first, and hosts without + cpufreq (most VMs) have no paths at all. Returns the prior governors. + """ + saved: dict[Path, str] = {} + for path in sorted(CPU_SYSFS.glob("cpu*/cpufreq/scaling_governor")): + try: + saved[path] = path.read_text().strip() + path.write_text("performance\n") + except OSError: + saved.pop(path, None) + + if saved: + info(f"› CPU governor set to performance ({len(saved)} CPUs)") + return saved + + +def restore_cpu_governors(saved: dict[Path, str]) -> None: + """Only matters when an install fails and the user keeps using the live + environment — a successful one reboots out of it.""" + for path, governor in saved.items(): + try: + path.write_text(f"{governor}\n") + except OSError: + continue + + # ───────────────────────────────────────────────────────────────────────────── # cleanup_bind_mounts: invoked from main()'s finally so bind mounts get # unwound on success, failure, or interrupt. Idempotent.