Canonical Company
By default, when saving a memory dump for hibernation, the kernel saves memory as is with all caches, but there is a native ability to release extra structures by simulating resource shortage conditions at the initial stage of hibernation. This feature can be enabled using the "/sys/power/image_size" parameter and results in a noticeable reduction in the time to enter sleep mode. Canonical suggests adding two more parameters "/sys/power/mm_reclaim/run" and
"/sys/power/mm_reclaim/release", which will allow you to cause the release of extra structures in advance so that the actual transition to sleep mode is completed as quickly as possible, and the return from sleep mode takes about the same time as when applying the existing one in kernel parameter "/sys/power/image_size".
Testing on a system with 8 GB of RAM and 8 GB of the swap partition with 85% of the memory utilized showed in the default settings (image_size=default) a decrease in the transition time to sleep from 51.56 to 4.19 seconds when initiating the process of cleaning excess memory 60 seconds before switching to sleep mode. By reducing the size of the saved memory image, the recovery time has decreased from 26.34 to 5 seconds. When the regular mode of cleaning excess memory (image_size=0) was enabled in the system, the time to enter sleep mode was reduced from 73.22 to 5.36 seconds, and the time to return from sleep mode practically did not change (it decreased only by a fraction of a second, from 5.32 to 5.26 seconds).
The proposed method can be used in situations where it is necessary to switch to sleep mode very quickly and it is possible to foresee the need for such a transition in advance. For example, in cloud systems, low-priority virtual environments (
Source: opennet.ru