Run the live CPUs at the performance governor during install (#89)
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 <davydotcom@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2 files changed
+39
No files matched your search
@@ -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:
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user