From 89245f44ece18f0cdc4b8a8c3edbc65c7b8c5136 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 27 Jul 2026 16:16:16 -0700 Subject: [PATCH] Warm the offline mirror while the user answers the wizard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The install reads ~3GB out of the offline mirror, and pacman consumes it at only ~33MB/s (3.14GB of packages across the 95s the package phase is calibrated at), so on any medium slower than that the install is read-bound. The ISO medium is idle for the minutes the wizard takes, and the target disk written to later is a different device, so reading ahead costs nothing that is otherwise in use. Warms largest-first under a MemAvailable/2 budget. Deliberately no dependency resolution: asking pacman exactly which files the install will read would copy the package-set knowledge in phases_impl.py — the early list, the runtime target, the kernel from the wizard's JSON — into a shell script that would drift silently. The install reads roughly 69% of the mirror, so warming blindly is close enough for a cache hint. The page cache this fills is clean and reclaimable, so the failure mode under memory pressure is wasted bandwidth rather than OOM. The budget stops small machines evicting what was just warmed. The job ends when that budget is spent rather than when the wizard exits, because the partitioning and format window afterwards is also free medium time. OMARCHY_NO_PREFETCH=1 turns it off so a single ISO can measure both arms against the Installing Arch + Omarchy entry in /var/log/omarchy-install-timing.json. Not yet measured on real USB media, and expected to be worth nothing in the VM harness, where the ISO is backed by the host's page cache. Co-Authored-By: Claude Opus 5 (1M context) --- configs/airootfs/root/.automated_script.sh | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/configs/airootfs/root/.automated_script.sh b/configs/airootfs/root/.automated_script.sh index a0b2b9d..28666c4 100644 --- a/configs/airootfs/root/.automated_script.sh +++ b/configs/airootfs/root/.automated_script.sh @@ -57,6 +57,39 @@ if [[ ${OMARCHY_INSTALL_DEBUG:-} == "1" ]]; then echo "================================" fi +# Warm the page cache for the bundled packages while the user works through the +# wizard. The install reads ~3GB out of the offline mirror, and pacman consumes +# it at only ~33MB/s, so on media slower than that the install is read-bound and +# every byte cached here is a byte it never waits for. On faster media this costs +# nothing but otherwise-idle bandwidth: the medium is untouched while the user +# types, and the target disk it writes to later is a different device. +# +# Clean page cache only, so the kernel reclaims it under pressure instead of +# OOMing, and a budget so small machines never evict what was just warmed. +# Set OMARCHY_NO_PREFETCH=1 to A/B the same ISO with this disabled. +warm_offline_mirror() { + local mirror=/var/cache/omarchy/mirror/offline + local budget_kb spent_kb=0 size_kb path + + [[ ${OMARCHY_NO_PREFETCH:-} == 1 ]] && return 0 + [[ -d $mirror ]] || return 0 + + budget_kb=$(($(awk '/^MemAvailable:/ { print $2 }' /proc/meminfo) / 2)) + ((budget_kb > 262144)) || return 0 + + # Largest first: the install reads most of the mirror, so when the budget + # cannot cover all of it this still front-loads the bytes that dominate. + while read -r size_kb path; do + ((spent_kb + size_kb > budget_kb)) && continue + cat -- "$path" >/dev/null 2>&1 || true + spent_kb=$((spent_kb + size_kb)) + done < <(du -k "$mirror"/*.pkg.tar.zst 2>/dev/null | sort -rn) +} + +warm_offline_mirror & +warm_pid=$! +trap 'kill "$warm_pid" 2>/dev/null' EXIT + cd /root ./configurator