Significant performance difference between partials / components when nesting #936
-
Just wanted to emphasize what we've found while looking into VC. Performance is talked about in the benchmarks, and we've seen a significant difference in speed when it comes to rendering nesting partials/components. Our use case: we were attempting to build "components", but using partials to do so, with helpers to call them. Ex: <!-- show.html.erb -->
<%= card title: "Recent Events" do %>
<%= card_list_item ... %>
<%= card_list_item ... %>
<% end %> # helpers/theme_helper.rb
def card(options = {}, &block)
render partial: "application/cards/card", locals: {...}
end <!-- application/cards/card -->
<div class="card <%= classnames %>">
<div class="card-body">
<%= capture(&block) %>
</div>
<% end %> etc. We started seeing pretty poor performance as soon as we had to output collections to render a partial, that renders a partial, that renders a partial, etc. To the point where we had to start pulling those partials into methods directly, using tag helpers. In just basic testing, we've seen that These are screenshots when rendering (10k items for emphasis): PartialsComponentsHere's an issue we have on Rails/Rails going through it, for full context. Thanks for all your hard work on this project, it's super exciting! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Are those benchmarks from Rails "development" mode with |
Beta Was this translation helpful? Give feedback.
-
For more recent discussion, see #906. |
Beta Was this translation helpful? Give feedback.
For more recent discussion, see #906.