Canonical has proposed patches to speed up the activation of sleep mode

Canonical Company suggested on the Linux kernel developer mailing list, a set of patches with the implementation of opportunistic memory purge ("opportunistic memory reclaim"), which can significantly reduce the time to enter sleep mode. Optimization is achieved by proactively calling the release operation of secondary memory structures that do not contain unique information and can be dynamically restored after returning from sleep mode (for example, areas anonymous memory and various page caches). The main idea is that after removing unnecessary data, the size of the memory image to save before going into sleep mode is reduced and, accordingly, it takes less time to write to and read from slow media.

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 (spot environments in Amazon EC2) can be dynamically hibernated and reclaim memory as resource consumption grows in primary environments. When the load on the primary environments decreases, the low-priority environments come back from hibernation. Under these conditions, to maintain the proper quality of service, it is important to minimize the time to enter and exit sleep mode. The preemptive cleanup phase can be triggered when a certain level of main load is reached, preceding the level that leads to the freezing of low-priority environments.

Source: opennet.ru

Add a comment