Microsoft has implemented in WSL2 (Windows Subsystem for Linux) the return of memory to the system

Microsoft company announced about expanding the capabilities of the WSL2 (Windows Subsystem for Linux) layer, which provides the launch of Linux executable files in Windows. In experimental builds Windows Insider (build 19013) The WSL2 layer added support for reclaiming memory (Memory Reclamation) freed by processes running in a Linux kernel-based environment.

Previously, in the event of an increase in memory consumption by applications or the kernel, memory was allocated to the WSL2 virtual machine, but after that it remained pinned and not returned to the system, even after the resource-intensive process ended and there was no further need for allocated memory. The Memory Reclamation mechanism allows you to return the freed memory to the main OS and automatically reduce the size of the virtual machine's memory. This returns not only the memory freed by user processes, but also the memory used for caching in the Linux kernel. For example, with high disk activity, the size of the page cache increases, in which the contents of files settle during the operation of the FS. After executing "echo 1 > /proc/sys/vm/drop_caches" the cache can be cleared and the memory returned to the main OS.

The implementation of Memory Reclamation is based on
patch, proposed by Intel engineers for inclusion in the mainstream Linux kernel in order to extend the capabilities of the virtio-balloon driver and for the memory management system. This patch is designed to be used in any guest systems to return unused memory pages to the host system and can be applied with various hypervisors. In the case of WSL2, the patch is adapted to return memory to the Hyper-V hypervisor.

Recall that the second edition of WSL is different delivery of a full-fledged Linux kernel instead of an emulator that translates Linux system calls into Windows system calls on the fly. Shipped in WSL2 Linux kernel based on release 4.19, which runs in a Windows environment using a virtual machine already in use in Azure. Updates for the Linux kernel are delivered through the Windows Update mechanism and tested on Microsoft's continuous integration infrastructure. WSL2-specific patches applied in the kernel include optimizations to reduce kernel startup time, reduce memory consumption, and keep the core set of drivers and subsystems as minimal as possible.

Source: opennet.ru

Add a comment