Repository navigation
Conversation
Automated AI review
Verified: the new Verified hook behavior (a copy of the hook with
The head also merges cleanly with the current Existing hibernation setups never receive the hook
A copy of the setup script with a stubbed Impact: the Omarchy ISO installer runs hibernation setup by default, so machines installed from it on supported hardware already have the marker. They get the updated source under Suggested change: either add a migration that checks for the resume marker and installs the hook when it is absent (the staging helper in Install and removal claims in the PR description
Suggested change: correct the description. If the hook stays setup-installed, remove it in Hook comment and measurements overstate the effect
Suggested change: correct the comment, and report a few runs of total hibernation entry time together with the Optional: Review informationTest scope: reviewed head AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check. Opt out: To stop receiving these reviews, reply to this comment saying so. |
…re snapshot Hibernation entry stalls for 70s+ under heavy memory because the single-threaded snapshot allocation has to reclaim clean page cache inside the shrinker walk. The kernel discards those caches anyway when it needs memory for the image — doing it up front with `echo 3 > /proc/sys/vm/drop_caches` turns the storm into an instant shrink. Measured on HP 250 G9 (i5-1235U, 15G RAM, zram zstd): Allocated 6756924 kbytes in 72.66s (92.99 MB/s) -> 6756564 kbytes in 57.15s (118.22 MB/s) 15.5s faster (21%) heavy-memory hibernate, 2.4s light case unchanged. systemd-hibernate.service: 57.233s CPU over 58.628s wall (confirming CPU-bound reclaim). Also drive `/sys/power/hibernate_compression_threads` to nproc at hibernate-entry time (default 3, this machine 12) so image compression scales with cores without a boot-time tmpfiles rule. Guarded to no-op on suspend and older kernels without the knob.
The hook comment claimed the drop "turns a ~70s CPU-bound stall into an
instant shrink". It does not: the measurement was 72.66s to 57.15s, with the
remaining entry time being anonymous pages evicted into zram, and the
explanation offered for the gain ("the kernel discards clean caches anyway")
does not hold under Omarchy's vm.swappiness=150, where reclaim favours
anonymous pages over file cache. What the comment now says is what was
measured, and separately what reads out of mm/vmscan.c.
Also corrected: writing nproc asks for nproc-1 compression threads rather
than nproc (the kernel clamps to num_online_cpus()-1), it replaces any lower
value a hibernate_compression_threads= boot parameter set, and the knob is
Linux 6.19 and later. Level 3 also frees reclaimable dentries and inodes that
cost something to rebuild after resume; that trade-off is now stated instead
of implied, and the level stays at the measured configuration.
Comment-only: the hook's behavior is unchanged.
… hibernate omarchy-hibernation-setup returns as soon as it sees the resume marker, and that marker is what "already configured" means, so the hook added for new setups never reached machines set up before it existed - including every machine the ISO installer configured, since it runs hibernation setup by default. Re-running setup could not help either: it exits at the same marker. A migration installs the hook where the marker is present and the hook is absent. It mirrors the literal check setup uses, so it decides on the same condition, and it only supplies what is missing: a hook that is already there belongs to whoever put it there. Its privileged paths stay fixed literals, as the other migrations do, so a caller cannot choose what root writes. Hibernation removal now removes the hook as well, rather than leaving it behind as inert litter, and docs/file-layout.md names drop-caches with the other conditional system-sleep sources and records the limit that none of them are package-owned - a later edit reaches installed machines only through another migration. That limit is also what the PR description now says, instead of calling the hook package-owned. Tested on a retargeted copy of the migration with a stubbed sudo: installs the shipped file at 0755 through the absolute installer, is idempotent, leaves an existing hook untouched, and does nothing without the resume hook line. Mutants that drop either guard fail it.
257aa42 to
b7fcd59
Compare
|
Fixed at Delivery. Added I went with the migration over Ownership claims. All three corrected rather than defended. "Package-owned under Hook comment and measurements. The "~70s CPU-bound stall into an instant shrink" claim is gone; it never matched the numbers I posted (72.66 s → 57.15 s, with the rest being anon eviction into zram). The comment now separates what was measured from what I read in On measuring properly: I can't do repeated hibernations from here, so rather than imply a series I labelled both figures as single runs on one machine and spelled out that Optional point: kept |
Summary
Hibernation with a browser-heavy working set stalls for over a minute on the snapshot allocation. Dropping clean caches before that allocation, and letting image compression use more than the default three threads, cut 15 s off the heavy path in single-run measurements on one machine.
Before:
PM: hibernation: Allocated 6756924 kbytes in 72.66s (92.99 MB/s)After:
Allocated 6756564 kbytes in 57.15s (118.22 MB/s)The remaining ~57 s is anonymous pages being evicted into zram, which dropping clean caches does not touch. Light hibernations are fine at 2.4 s already.
What these numbers do and don't show.
Allocated ... incovers the snapshot allocation only, which is why it reflects the cache drop and cannot reflect the compression-threads change: compression runs later, when the image is written. The lines that would show it are the kernel'sUsing N thread(s) for lzo compressionandWrote ... kbytes in, which I have not collected across runs — so the thread change is claimed as making compression parallel, not as measured seconds. Both figures above are one before/after pair on one machine, not a series; I have not repeated them.What changed
default/systemd/system-sleep/drop-caches(new,0755) —pre hibernateonly, guarded for suspend/s2idle and for the suspend half of suspend-then-hibernate. Syncs, setshibernate_compression_threadswhen the knob exists, then drops caches.nprocasks fornproc - 1compression threads: the kernel clamps tonum_online_cpus() - 1. The write also replaces any lower value ahibernate_compression_threads=boot parameter set. The knob exists from Linux 6.19; older kernels skip it through the-wguard.vm.vfs_cache_pressurenote. Kept at 3 because that is the measured configuration;echo 1(page cache only) is the obvious comparison if we want to shrink that cost, and post-resume responsiveness would be the thing to check.vm.swappiness=150, reclaim favours anonymous pages over file cache. The plausible mechanism (readingmm/vmscan.c, not measured) is that the allocator has less clean cache to compress on the way into the image.bin/omarchy-hibernation-setup— installs the hook alongsidekeyboard-backlightthroughinstall_root_file.migrations/1790692395.sh(new) — installs it on machines that already hibernate, which is most of them: the ISO installer runs hibernation setup, and setup returns at the resume marker before reaching the install step, so neither a re-run nor--forcecould ever deliver it. The migration mirrors that same marker check and only supplies a hook that is missing.bin/omarchy-hibernation-remove— removes the hook, so removing hibernation does not leave it behind.docs/file-layout.md— namesdrop-cacheswith the other conditional system-sleep sources.Ownership, stated correctly
The hook is not package-owned.
install_root_filewrites an unowned root-owned file, exactly likekeyboard-backlightandforce-igpu; onlyunmount-fusecomes fromomarchy-settings. Consequences worth knowing:/usr/lib/systemd/system-sleepdirectory thatunowned-system-paths-test.shallowlists as a whole; that test's own install assertions coverkeyboard-backlight, not this hook.No
/etcwrites for the thread knob. The sysfs write is conditional on-w, so kernels withouthibernate_compression_threadsno-op.Measurements
HP 250 G9, 12th Gen i5-1235U (12 threads), 15 GiB RAM,
zram0zstd15.2 GiB. Same ~11 GiB working set,journalctl -k | grep "Allocated.*kbytes in":Single runs each.
systemd-hibernate.service: Consumed 57.233s CPU over 58.628s wallsays the remaining time is CPU-bound, consistent with anon-page eviction rather than disk. Thezstd/lz4comparison (810 MiB in 1.0 s vs 0.5 s, 3.5× worse ratio) said switching compression would save ~5–8 s while shrinking effective zram, so I dropped it.Resume is unaffected.
suspend(s2idle) is unaffected — the hook exits early whensleep_action != hibernate.Testing
test/shell.d/hibernate-drop-caches-migration-test.sh(new) — runs a retargeted copy of the migration with a stubbedsudo: installs the shipped file at0755through the absolute privileged installer, is idempotent, leaves an existing hook alone, and does nothing without the resume hook line. It also asserts the production paths stay fixed literals so a caller cannot choose what root writes, and that setup, the migration and hibernation removal are the hook's only owners. Mutants that drop either guard fail it.systemctl hibernatewith a heavy browser session, comparingjournalctl --sinceAllocatedlines before and after.PM: suspend entry (s2idle)path still immediate,drop_cachesnot triggered.cat /sys/power/hibernate_compression_threadsreads back after pre-hibernate, no error on kernels without the file.bash -non hook, setup and migration;bin-style-test,manifest-entrypoints-test,migrate-scope-test,migrate-wrapper-test,system-sleep-ownership-migration-testpass.