Skip to content

Use compiled templates to speed up generation - #1843

Closed
skatkov wants to merge 4 commits into
ruby:masterfrom
skatkov:compiled-template
Closed

skatkov wants to merge 4 commits into
ruby:masterfrom
skatkov:compiled-template

Conversation

@skatkov

@skatkov skatkov commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Cache executable ERB renderers for bundled Aliki and Darkfish pages and partials instead of repeatedly evaluating their Ruby source.

Benchmark

Metric Clean master Patched Change
Generation wall time 17.92s 11.14s −37.83%
Generation CPU time 17.91s 11.14s −37.83%
End-to-end wall time 20.19s 13.44s −33.43%
Parsing wall time 1.80s 1.79s Essentially unchanged
Generation allocations 24,936,295 24,363,184 −2.30%
Peak RSS 335.3 MiB 366.2 MiB +9.22%

Individual generation times

Run Clean master Patched
1 17.92s 11.14s
2 18.51s 11.18s
3 17.90s 11.14s

This optimization works only for Aliki and Darkfish templates. 'ri' is not affected.

Notes

  • ERB#def_module compiles in ERB’s lexical scope, so bare VERSION resolves to ERB::VERSION, not RDoc’s. So this change requires to explicitly define ::RDoc::VERSION.

@github-actions

github-actions Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Documentation preview

View the preview

Commit: bbd81c2

@skatkov skatkov changed the title Use compiled templates Use compiled templates to speed up generation Oct 4, 2026
@skatkov

skatkov commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

Interesting experiment.

There is an interesting performance gain here, but I can't really find an implementation that doesn't come with drawbacks.

I will close for now.

@skatkov skatkov closed this Oct 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.

1 participant