Skip to content

Lazy page index in RDoc::Store (42.7% perf improvement) - #1811

Open
skatkov wants to merge 2 commits into
ruby:masterfrom
skatkov:page-index
Open

Lazy page index in RDoc::Store (42.7% perf improvement)#1811
skatkov wants to merge 2 commits into
ruby:masterfrom
skatkov:page-index

Conversation

@skatkov

@skatkov skatkov commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

RDoc::Store#page previously scanned every known file for each page lookup, including repeated misses.

This adds a lazily built hash index keyed by both page_name and base_name, preserving existing first-match behavior when names collide.

The index is invalidated whenever files are added, removed, or bulk-loaded. The implementation remains private to RDoc::Store and adds no public API or configuration.

Benchmark

For testing I used latest rdoc(master) + rdoc-markdown gem. Generation was done on a rails codebase.

Metric Before After Change
Generation time 74.91s 42.08s -43.8%
Total time 88.52s 50.76s -42.7%
Peak RSS 411.1 MiB 422.8 MiB +2.8%

Total time to generate documentation decreased from 88.52s to 50.76s (42.7%).

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: 54d2b50

@skatkov skatkov changed the title Implemented the lazy page index in RDoc::Store, Implemented lazy page index in RDoc::Store (42.7% perf improvement) Sep 4, 2026
@skatkov
skatkov marked this pull request as ready for review September 4, 2026 16:13
Copilot AI balanced review requested due to automatic review settings September 4, 2026 16:13

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.

🟢 Approval recommended

The indexed lookup preserves existing semantics and is covered across mutation and loading paths.

Pull request overview

Adds a lazy page lookup index to improve repeated page resolution performance while preserving first-match behavior.

Changes:

  • Indexes page and base names on first lookup.
  • Invalidates the index when files change or load.
  • Adds performance and invalidation tests.
File summaries
File Description
lib/rdoc/store.rb Implements and invalidates the lazy page index.
test/rdoc/rdoc_store_test.rb Tests scaling and cache invalidation.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@skatkov skatkov changed the title Implemented lazy page index in RDoc::Store (42.7% perf improvement) Lazy page index in RDoc::Store (42.7% perf improvement) Sep 4, 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.

2 participants