Roman Gushchin () from Facebook in the mailing list of Linux kernel developers a set of patches has been proposed for a new memory distribution controller (slab memory controller). The new controller is notable for transferring the slab accounting from the page level to the kernel object level, allowing slab pages to be shared across cgroups, rather than allocating separate slab caches for each cgroup.
The proposed approach allows for a more efficient use of slab, reducing the size of slab memory used by 30-45% and significantly lowering the total memory consumption by the kernel. By reducing the number of pinned slabs, there is also a positive effect on reducing memory fragmentation. The new memory controller greatly simplifies slab accounting code and does not require complicated dynamic algorithms for creating and deleting slab caches for each cgroup. All memory cgroups in the new implementation use a common set of slab caches, and the lifetime of the slab caches is no longer tied to the lifetime established through the cgroup for memory usage.
The more accurate resource accounting implemented in the new slab controller should theoretically increase CPU load, but in practice, the differences have proven negligible. In particular, the new slab controller has been in use for several months on Facebook's production servers handling various types of loads, and no significant regressions have been observed. At the same time, a substantial reduction in memory consumption has been notedâon some hosts, savings of up to 1GB of memory have been achieved, although this figure varies greatly depending on load characteristics, total RAM size, CPU count, and memory usage patterns. Previously conducted tests showed a memory consumption reduction of 650-700 MB (42% of slab memory) on the web frontend, 750-800 MB (35%) on a database cache server, and 700 MB (36%) on a DNS server.
Burimi: opennet.ru
