aifollow.news
返回 IT之家 科技新闻
IT之家 科技新闻· · 原发布时间 AI 评分47

Collabora Online 调整进程内存分配,测试中文档内存占用最多降约 55%

AI 辅助摘要

Collabora Online 在创建文档进程前填满父进程已分配内存中的空隙,以减少共享页面被复制。在一台 4 核、8 GB 服务器上模拟 10 人同时编辑时,空白文本文档的单份内存占用从 53.9 MB 降至 24.4 MB;Collabora 估计,约 1000 人同时使用的场景最多可节省 25 GB 内存。

正文 · AI 翻译

IT Home reported on November 27 that tech outlet NeoWin published a post yesterday (November 26) saying that, as AI is used more extensively, a large number of open-source alternatives to Microsoft Office have emerged. In addition to WordCraft, GridCraft, DeckCraft and Starling Office, the latest Collabora Online project has announced a major breakthrough in memory usage.

Collabora Online is a cloud-based online office suite built on LibreOffice technology. As a self-hostable alternative to Microsoft 365, it lets users create, view and collaboratively edit text documents, spreadsheets, presentations and vector drawings in real time in a browser.

The Collabora team noted that, in its original architecture, Collabora Online created a separate process, called a kit, for each open document to improve isolation and stability. This meant that if one document crashed or encountered an error, other documents would usually be unaffected.

But if every kit loaded the entire office suite, memory use would be very high. Collabora therefore uses a parent process, forkit, to load the office software once before creating each document process through Linux's fork mechanism. Initially, these child processes share the same read-only memory with the parent process.

Linux uses Copy-on-Write (COW) to save memory: the parent and child processes initially share the same physical memory pages, and the kernel makes a separate copy of a page for a child process only when that process needs to modify data on it. Ideally, all kits can share the unchanged base code, fonts, configuration and initialization data in forkit, with copies needed only for data that is actually modified.

The problem is that Linux typically manages memory in 4 KB pages. Even if a document process changes only a few bytes on a shared memory page, the operating system must copy the entire 4 KB page for that process.

Collabora developer Meven Car explained that after forkit creates and discards temporary data, it leaves many small gaps in allocated memory. When document processes later use those gaps, they trigger unnecessary copies of entire pages.

Collabora's solution is to fill those gaps in the parent process, forkit, before creating the first document process. New data for each document process is then allocated to entirely new memory pages, while pages that could already be shared remain intact, avoiding repeated copying after they are “contaminated.”

This may sound as though it would increase memory use, but because the gaps already exist within memory allocated to forkit, filling them only changes how memory is allocated. According to Collabora, the operation needs to run only once when the server starts and takes about 11 milliseconds. In tests, the parent process's memory use did not increase even after 160 document processes were created.

On a server with a 4-core processor and 8 GB of memory, Collabora simulated 10 users opening and editing documents at the same time. The results showed that memory use per blank text document fell from 53.9 MB to 24.4 MB, a reduction of about 55%; per ordinary Writer document, from 73.6 MB to 47.8 MB, about 35%; and per Impress presentation, from 72.1 MB to 50.3 MB, about 30%.

Document type | Memory per document before optimization | Memory per document after optimization | Reduction

Blank text document | 53.9 MB | 24.4 MB | About 55%

Writer document | 73.6 MB | 47.8 MB | About 35%

Impress presentation | 72.1 MB | 50.3 MB | About 30%

Collabora estimates that, on a heavily loaded server serving about 1000 users simultaneously, this optimization could save up to 25 GB of memory. Against a backdrop of rising memory costs, this means lower hardware costs and greater capacity to handle concurrent workloads for businesses, schools and cloud service providers that need to support large numbers of online document editing tasks.

发现内容有误?提交纠错