Skip to content

Add memoized page lookup index to RDoc::Store - #1794

Closed
skatkov wants to merge 1 commit into
ruby:masterfrom
skatkov:page-index
Closed

Add memoized page lookup index to RDoc::Store#1794
skatkov wants to merge 1 commit into
ruby:masterfrom
skatkov:page-index

Conversation

@skatkov

@skatkov skatkov commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

page(name) currently resolves page lookups by scanning every TopLevel in @files_hash each time it’s called (each_value.each_with_object(...)). In large documentation sets (or in server/live reload flows where lookups happen repeatedly), this results in repeated linear scans.

This PR introduces @page_index as a memoized secondary index keyed by both page_name and base_name to avoid that repeated work and make page lookup O(1) on steady-state access.

Benchmarks

Based on my findings, speed-up is noticeable in gems with many pages. This improvement doesn't affect smaller gems.

-> TODO: add exact numbers

@skatkov
skatkov requested a deployment to fork-preview-protection August 29, 2026 09:28 — with GitHub Actions Waiting
@skatkov

skatkov commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

So, after testing more... this speed up is barely <2% insignificant

@skatkov skatkov closed this Aug 29, 2026
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.

1 participant