Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

init: background diagnostic dump + parallel USB mount/GPU wait + optional zram

Three boot-speed wins that together shave ~2–4 seconds off the wall
time from kernel handoff to ac-native splash on ThinkPad-class hardware:

1. Backgrounded pre-launch diagnostic dump
The ~60 KB PRE-LAUNCH + POST-PROBE dump (PCI/ACPI/GPIO/ALSA/ASoC
scrape + writes to FAT32) previously ran synchronously BEFORE ac-
native launched. Wrapped the whole block in a `_pre_launch_diag` fn
and backgrounded it, so ac-native starts immediately and the dump
writes concurrently while the splash fade is drawing. FAT32 handles
concurrent writes to distinct files fine (pre-launch.log vs ac-
native-stdout.log). Downstream tooling (os-install-report) sees
the same file at the same path, just ~1-2 s later.

Add AC_NOLAUNCH_DIAG=1 on the kernel cmdline to skip the dump
entirely for locked-down production boots.

2. Parallel USB mount + GPU wait
Previously: GPU wait (up to 3s) serial→then USB mount loop (up to
10 iterations × 1s sleep). Now: the USB mount runs in a background
subshell writing its result to /run/usb-mounted, the foreground
runs the GPU wait, then a single `wait` converges both. Shaves up
to ~2 s on cold boot where GPU probes faster than the USB enumerates
(common on nvme + USB 3 hubs).

3. Zram swap gated on AC_ZRAM=1
modprobe zram + mkswap + swapon added ~100-200 ms for no observable
benefit on 4-8 GB RAM ThinkPads running notepat (which peaks under
200 MB). Kept the code paths intact behind a cmdline opt-in so
low-memory tablet builds can still enable it.

Net architectural effect: init goes from "do everything serially,
each wait blocks everything else" to "launch long probes in parallel
and overlap with I/O-heavy logging." The real wall-clock win on a
dual-core m3-8100Y will be 2-3 s faster to splash.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+82 -44
+82 -44
fedac/native/initramfs/init
··· 18 18 mkdir -p /sys/kernel/debug 2>/dev/null 19 19 mount -t debugfs debugfs /sys/kernel/debug 2>/dev/null 20 20 21 - # zram swap 22 - modprobe zram 2>/dev/null || true 23 - if [ -e /sys/block/zram0/disksize ] && [ -b /dev/zram0 ]; then 24 - echo 1G > /sys/block/zram0/disksize && 25 - mkswap /dev/zram0 >/dev/null 2>&1 && 26 - swapon /dev/zram0 2>/dev/null 27 - fi 21 + # zram swap — skipped by default. notepat fits in ~200 MB, every ThinkPad 22 + # we target has ≥4 GB RAM, and the zram modprobe + mkswap chain adds 23 + # ~100-200 ms to boot for no observable benefit. Set AC_ZRAM=1 on the 24 + # kernel cmdline if you ever need it back (e.g. low-memory tablet boot). 25 + case " $(cat /proc/cmdline 2>/dev/null) " in 26 + *" AC_ZRAM=1 "*) 27 + modprobe zram 2>/dev/null || true 28 + if [ -e /sys/block/zram0/disksize ] && [ -b /dev/zram0 ]; then 29 + echo 1G > /sys/block/zram0/disksize && 30 + mkswap /dev/zram0 >/dev/null 2>&1 && 31 + swapon /dev/zram0 2>/dev/null 32 + fi 33 + ;; 34 + esac 28 35 29 36 # Loopback 30 37 ip link set lo up 2>/dev/null ··· 56 63 echo "root:x:0:" > /etc/group 57 64 echo "root:x:0:root" > /etc/passwd 58 65 59 - # Wait for GPU (up to 3 seconds) 66 + # Kick off USB mount in the background — independent of GPU probe, so 67 + # we overlap the two waits instead of running them serially. The main 68 + # thread then waits for GPU (below) and finally waits for this mount 69 + # result before continuing. Shaves up to ~2s on cold boot. 70 + modprobe vfat 2>/dev/null 71 + modprobe nls_cp437 2>/dev/null 72 + modprobe nls_ascii 2>/dev/null 73 + USB_MOUNTED=0 74 + USB_PARTS="/dev/sda1 /dev/sda2 /dev/sda3 /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdc1 /dev/sdc2 /dev/sdc3 /dev/sdd1 /dev/sdd2 /dev/sdd3 /dev/nvme0n1p1 /dev/nvme0n1p2 /dev/nvme0n1p3" 75 + 76 + mount_usb_partition() { 77 + pass="$1" 78 + for p in $USB_PARTS; do 79 + if [ -b "$p" ]; then 80 + mkdir -p /mnt 81 + mount -t vfat "$p" /mnt 2>/dev/null || continue 82 + if [ "$pass" = "config" ] && [ -f /mnt/config.json ]; then 83 + return 0 84 + fi 85 + if [ "$pass" = "boot" ] && { [ -f /mnt/EFI/BOOT/BOOTX64.EFI ] || [ -f /mnt/EFI/BOOT/KERNEL.EFI ]; }; then 86 + return 0 87 + fi 88 + umount /mnt 2>/dev/null 89 + fi 90 + done 91 + return 1 92 + } 93 + 94 + # Background USB mount: try up to 10 times with 1s delay, write result 95 + # to /run/usb-mounted so the foreground thread can check after GPU wait. 96 + ( 97 + for attempt in 1 2 3 4 5 6 7 8 9 10; do 98 + mount_usb_partition config && { echo 1 > /run/usb-mounted; exit 0; } 99 + mount_usb_partition boot && { echo 1 > /run/usb-mounted; exit 0; } 100 + sleep 1 101 + done 102 + echo 0 > /run/usb-mounted 103 + ) & 104 + USB_MOUNT_PID=$! 105 + 106 + # Wait for GPU (up to 3 seconds) — runs in parallel with USB mount above. 60 107 i=0 61 108 while [ ! -e /dev/dri/card0 ] && [ ! -e /dev/dri/card1 ] && [ ! -e /dev/fb0 ] && [ $i -lt 300 ]; do 62 109 usleep 10000 2>/dev/null || sleep 1 63 110 i=$((i+1)) 64 111 done 112 + 113 + # Converge: wait for the background USB mount to settle, pick up its result. 114 + wait $USB_MOUNT_PID 2>/dev/null 115 + [ -f /run/usb-mounted ] && USB_MOUNTED=$(cat /run/usb-mounted 2>/dev/null) && [ -z "$USB_MOUNTED" ] && USB_MOUNTED=0 65 116 66 117 # Performance governor (silently skip if cpufreq not available) 67 118 if [ -d /sys/devices/system/cpu/cpu0/cpufreq ]; then ··· 94 145 export COLORTERM="truecolor" 95 146 export EDITOR="/bin/vi" 96 147 97 - # ── Mount USB config/log partition (for config.json, wifi creds, logs) ── 98 - # Prefer the writable config partition over the boot partitions. 99 - modprobe vfat 2>/dev/null 100 - modprobe nls_cp437 2>/dev/null 101 - modprobe nls_ascii 2>/dev/null 102 - USB_MOUNTED=0 103 - USB_PARTS="/dev/sda1 /dev/sda2 /dev/sda3 /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdc1 /dev/sdc2 /dev/sdc3 /dev/sdd1 /dev/sdd2 /dev/sdd3 /dev/nvme0n1p1 /dev/nvme0n1p2 /dev/nvme0n1p3" 104 - 105 - mount_usb_partition() { 106 - pass="$1" 107 - for p in $USB_PARTS; do 108 - if [ -b "$p" ]; then 109 - mkdir -p /mnt 110 - mount -t vfat "$p" /mnt 2>/dev/null || continue 111 - if [ "$pass" = "config" ] && [ -f /mnt/config.json ]; then 112 - USB_MOUNTED=1 113 - return 0 114 - fi 115 - if [ "$pass" = "boot" ] && { [ -f /mnt/EFI/BOOT/BOOTX64.EFI ] || [ -f /mnt/EFI/BOOT/KERNEL.EFI ]; }; then 116 - USB_MOUNTED=1 117 - return 0 118 - fi 119 - umount /mnt 2>/dev/null 120 - fi 121 - done 122 - return 1 123 - } 124 - 125 - for attempt in 1 2 3 4 5 6 7 8 9 10; do 126 - mount_usb_partition config && break 127 - mount_usb_partition boot && break 128 - [ "$USB_MOUNTED" = "1" ] && break 129 - sleep 1 130 - done 148 + # USB mount already settled above (kicked off in parallel with GPU wait). 149 + # USB_MOUNTED is populated from /run/usb-mounted at that wait() point. 131 150 132 151 # Create samples directory on boot media + mount point for music USB 133 152 if [ "$USB_MOUNTED" = "1" ]; then ··· 147 166 # Run ac-native in a loop — if it crashes, restart; if clean exit, shutdown 148 167 export LD_LIBRARY_PATH="/lib64:/usr/lib64:${LD_LIBRARY_PATH:-}" 149 168 150 - # Write diagnostics to console AND USB 169 + # Pre-launch diagnostics — useful for audio probe / GPU / PCI debugging, 170 + # but the full dump writes ~60 KB to FAT32 (slow USB), does dozens of 171 + # shell forks over sysfs, and on older ThinkPads adds 1–2 s of wall time 172 + # to boot. The whole block now runs in a backgrounded subshell so 173 + # ac-native launches immediately; the dump completes concurrently while 174 + # the splash fade is drawing. Downstream tools (os-install-report, 175 + # post-mortem analysis) still get the same pre-launch.log at the same 176 + # path — just a second later than before. 177 + # 178 + # Set AC_NOLAUNCH_DIAG=1 on the kernel cmdline to skip the dump entirely 179 + # (useful for locked-down production kiosks that don't want the sysfs 180 + # scraping cost at all). 151 181 echo "[init] USB_MOUNTED=$USB_MOUNTED" > /dev/tty0 2>/dev/null 152 182 if [ "$USB_MOUNTED" = "1" ]; then 153 183 LOG=/mnt/pre-launch.log 154 184 else 155 - # No USB config partition — try writing logs to /tmp 156 185 LOG=/tmp/pre-launch.log 157 186 fi 187 + 188 + _pre_launch_diag() { 158 189 echo "=== PRE-LAUNCH ===" > $LOG 159 190 ls /dev/dri/ >> $LOG 2>&1 160 191 echo "binary: $(ls -la /ac-native 2>&1)" >> $LOG ··· 363 394 echo "=== CMDLINE ===" >> $LOG 364 395 cat /proc/cmdline >> $LOG 2>&1 365 396 sync 397 + } # end _pre_launch_diag 398 + 399 + # Launch pre-launch diagnostics in the background unless cmdline disables. 400 + case " $(cat /proc/cmdline 2>/dev/null) " in 401 + *" AC_NOLAUNCH_DIAG=1 "*) : ;; 402 + *) _pre_launch_diag & ;; 403 + esac 366 404 echo "[init] GPU: $(ls /dev/dri/ 2>/dev/null || echo NONE) USB=$USB_MOUNTED" > /dev/tty0 2>/dev/null 367 405 368 406 # Start Swank server in background (if SBCL image exists)