Skip to content

Reduce Aliki’s peak memory usage by streaming search-index generation - #1874

Open
skatkov wants to merge 6 commits into
ruby:masterfrom
skatkov:stream-search-index
Open

skatkov wants to merge 6 commits into
ruby:masterfrom
skatkov:stream-search-index

Conversation

@skatkov

@skatkov skatkov commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

RDoc built the entire index in memory, then made two copies while preparing to save it. Resulting in 3 similar arrays of data stored in memory.

This PR brings a streaming approach to index creation: RDoc now writes one index entry at a time into a temporary file. Once everything is ready, it saves the finished index.

On the complete Google API Ruby Client documentation build—573 clients, 3,476 inputs, and 118,067 classes/modules—this reduced whole-build peak RSS from 4.33 GiB to 3.99 GiB, saving 350 MB (7.9%).

Metric Before After Change
Whole-build peak RSS 4,539,336 KiB 4,181,036 KiB 7.89% lower; 350 MiB saved
Complete RDoc build time 972.65 s 835.49 s 14.1% lower

The tradeoff is temporary disk space.

This change mainly brings peak RSS memory improvements. I see that with different codebases it also brings performance improvement for entire documentation generation, but this improvement heavily depends on library size (more code, better the improvement).

For performance, I have observed improvements from 14% to -3% (again, depending on library size). For minimal libraries this brings negative performance improvements, but time-wise performance degradation for these is not noticeable.

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: 0b965fd

@skatkov
skatkov force-pushed the stream-search-index branch from d227d77 to 9831f97 Compare November 4, 2026 13:21
@skatkov
skatkov marked this pull request as ready for review November 5, 2026 00:55
Copilot AI balanced review requested due to automatic review settings November 5, 2026 00:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants