Show Your Support: This site is primarily supported by advertisements. Ads are what have allowed this site to be maintained on a daily basis for the past 18+ years. We do our best to ensure only clean, relevant ads are shown, when any nasty ads are detected, we work to remove them ASAP. If you would like to view the site without ads while still supporting our work, please consider our ad-free Phoronix Premium.
Ubuntu Is Working On Much Faster Hibernation/Resume Support
When hibernating the system and needing to dump the entire contents of RAM to the swap/resume device, the kernel can try to free up some pages that don't need to be saved to disk where they can be easily regenerated at resume time without much overhead.
Due to the I/O involved in freeing up the system memory and writing the hibernation image to disk, this is one of the key bottlenecks but can be less so with Canonical's opportunistic memory reclaim patches. The opportunistic memory reclaim can allow user-space to trigger the memory reclaim / artificial memory pressure ahead of the actual hibernation process, such as when the system has been idle for a defined period of time and likely to be hibernated soon.
By carrying out that memory reclaim process ahead of time, the actual hibernation process is much faster as well as the resume time thanks to (ideally) having less to recover from the disk image. The request for comments patches expose new knobs via sysfs for triggering the process and a tunable for how many pages should try to be reclaimed.
While this can benefit all systems hibernating, the motivation by Canonical is focused on cloud instances that hibernate when other instances are being prioritized in its place. For being able to more quickly hibernate those instances when needed, the cloud infrastructure can respond better to changing needs/capacity.
The testing so far by Andrea Righi showed that with the opportunistic memory reclaim patches the hibernate process could drop from around 51 seconds to just 4 seconds in a default configuration or with the lowest image size going from 73 seconds to 5 seconds. In the default configuration, the resume process also sped up from 26 to 5 seconds.
For now the patches are out for review on the mailing list. It's too late for seeing the material in Linux 5.8 but hopefully could be mainlined in 5.9 if all goes well. Besides the kernel patches, in user-space you will also need to have integrated the respective triggering of this opportunistic memory reclaim after a defined idle threshold before hibernating or other policy for handling this task in advance of system hibernation.