Collabora Online Sharply Reduces Server Memory Use With New Optimization
The Collabora Online open-source web browser based office suite derived from LibreOffice is now able to use 50% less memory per document following an optimization to its copy-on-write memory handling...
Collabora Online has significantly reduced server memory usage through a new optimization technique. The issue arose from the forkit, which creates and discards numerous small objects like text snippets, lists, and settings. These objects leave behind gaps in memory that are not returned, resulting in scattered small gaps that memory allocators try to pack together for conservation.
When the forkit loads its document, the initial small objects it creates directly fill these gaps. Since the gaps reside in a shared page with the forkit, writing even a few bytes there requires copying the entire page. Consequently, a small amount of new data can waste up to 4 KB of memory. To address this, the forkit now preallocates its gaps before creating the first kit.
It reserves this space and avoids reusing it, allowing the kits it generates to find no gaps to reuse. Instead, they allocate fresh memory for their data, which is tightly packed into a few new pages. These pages remain shared with the forkit. Initially, this strategy might seem counterintuitive - the forkit allocates memory to save memory.
However, the gaps themselves do not cost the forkit any memory, as they are within pages it has already allocated. This optimization can lead to significant memory savings on a busy server serving a thousand concurrent users, potentially saving 25 GB of RAM. This technique, which involves allocating more memory to optimize memory usage, can be beneficial for other processes utilizing copy-on-write (COW) to enhance their children's performance.
Rewritten by urgent.news; may contain errors — check the original.
Source: phoronix.com