Hibernation Gets 18 to 25% Faster Writes by Asking for Contiguous Swap Slots
Hibernation writes your entire system memory to swap and reads it back on resume. Ten RFC patches from Youngjun Park at LG make both ends meaningfully faster by changing how the swap slots are chosen.
The idea
“This series improves how hibernation allocates swap slots for its image. It starts from a few observations about what happens while the image is written. With them the allocator can hand the image contiguous runs, the image I/O can be batched per run, and hibernation gets faster. Contiguous I/O pattern is friendly to flash device also.”
The existing allocator hands out slots without particular regard for whether they are adjacent. The hibernation image then gets written in pieces scattered across the swap area, and every scattered piece is a separate I/O request.
Asking for contiguous runs instead means the image lands in long stretches, and long stretches can be submitted as batches rather than as individual requests. Fewer, larger operations is close to a universal rule for storage performance.
The numbers
Measured in a QEMU VM, so treat them as indicative rather than final:
| Direction | Improvement |
|---|---|
| Write, meaning hibernate | 18 to 25% faster |
| Read, meaning resume | 11 to 20% faster |
The write side gains more, which makes sense. Writing is where the allocator decides placement, so that is where the layout improvement applies directly.
Why flash cares more
The note about flash devices is the part with a longer tail.
SSDs have an internal erase block size considerably larger than a filesystem block. Scattered small writes mean the controller reads, modifies and rewrites more than you asked it to, which costs throughput now and write endurance over time. That amplification is exactly what contiguous runs avoid.
On a laptop that hibernates daily, the difference is not only a faster hibernate. It is less wear on the drive doing it.
Who still hibernates
Fewer people than used to, and the ones who do tend to care a lot.
Suspend to RAM is faster and good enough for a lunch break. Hibernation is for when the battery would not survive, for machines that get carried around for days between charges, and for anyone who wants an exact session restored after a full power-off.
It also has an awkward relationship with encryption. A hibernation image is the complete contents of your memory written to disk, which includes anything sensitive that was in it. Unencrypted swap makes full disk encryption substantially less meaningful, which our LUKS guide covers, and resuming from an encrypted swap on a remote machine is the scenario our remote unlock with Dropbear guide exists for.
# is hibernation available and configured
cat /sys/power/state
swapon --show
# resume device the kernel will look for
cat /sys/power/resume
Your swap must be at least as large as the memory you expect to write, which is the same arithmetic behind the RFC to standardise video memory reporting posted two days later. Both come down to an installer needing a number nobody exposes cleanly.
Status
An RFC, and explicitly incomplete. No target release, and the numbers may move once it is tested on real storage rather than virtualised.
It is part of a broader run of kernel performance work this month, alongside the 39% faster file opens and kernel builds up to 70% faster incrementally, all of which share a shape: nobody had looked closely at an old path in a while.