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 Office opens each document in its own process "kit"and relies on copy-on-write memory handling to reduce memory use only to what has changed in memory for each process/kit. But with the copying be done on a (4KB) kernel page basis, it can lead to a lot of memory waste. Méven Car explained on the Collabora Online blog after authoring the optimization to address the memory use: "While the forkit gets the office suite ready, it creates and throws away a huge number of small things: bits of text, lists, settings. The space they leave behind isn’t given back. It stays as small gaps scattered across the forkit’s memory, ready to be reused. Normally memory allocators love to pack things into those gaps to conserve memory. Each kit inherits those gaps. When it loads its document, the first small things it creates go straight into them. Each gap sits in a page that the kit shares with the forkit, so writing even a few bytes there means copying the whole page. A few dozen bytes of new data can cost 4 KB of memory. ... The forkit now fills its own gaps before it creates the first kit. It reserves that space and never uses it. The kits it creates find no gaps to reuse, so they put their data in fresh memory instead, packed tightly into a few new pages. The pages they share with the forkit stay shared. It sounds backwards: the forkit takes memory to save memory. But the gaps cost the forkit nothing, because they are inside pages that it already has allocated. Each kit, have a major memory saving, avoiding copying every page it would have touched – not to mention the CPU time it used to cost to duplicate these pages." In the end when testing the change with 10 simulated users, memory usage per open document roughly halved for a blank text document. For Impress presentations and more were also significant memory savings. For Collabora Online servers with many users this can ultimately lead to significant memory savings: "On a busy server serving a thousand concurrent users we can save 25 GB of RAM – a great win with today’s RAM prices, and all from allocating more memory – to save memory. This is likely to be a technique that can and should be used by other processes leaning on COW to optimize their children’s performance, checkout the rather simple patch and enjoy." More details on this optimization via the Collabora Online blog.

Original Source

Read the full article at Phoronix →

KhanList aggregates and links to publicly available news content. We do not host full articles from third-party sources. Always verify important information with original sources.