Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Possible performance optimization for partial rendering #469

Closed
jaredcwhite opened this issue Nov 30, 2021 · 2 comments · Fixed by #489
Closed

feat: Possible performance optimization for partial rendering #469

jaredcwhite opened this issue Nov 30, 2021 · 2 comments · Fixed by #489
Labels
enhancement New feature or request

Comments

@jaredcwhite
Copy link
Member

As reported by @luctus, rendering a partial over thousands of iterations (aka in a layout) can cause an unexpected slowdown in build time. It's possible we're not effectively caching the compiled template through Tilt prior to final render, or some other issue. FWIW, using memoization helps, aka:

<%= site.data.cached_my_partial ||= render("my_partial") %>
@jaredcwhite jaredcwhite added the enhancement New feature or request label Nov 30, 2021
@jaredcwhite
Copy link
Member Author

(also worth benchmarking relative to using a dedicated Component)

@jaredcwhite
Copy link
Member Author

Wow, I just ran a benchmark where I loop 100,000 times and output the iteration number. Using a Ruby component + ERB template only took 1.2 seconds. Using an ERB partial took 17+ seconds! Yikes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant