S
S
sadgb2012-01-21 13:10:47
Ruby on Rails
sadgb, 2012-01-21 13:10:47

Ruby on Rails render performance problem

Hello, I have the following partials hierarchy, rendering of which results in a table

render :partial => table
--render :partial => row, :collection => rows
----render :partial => cell, :collection => row.cells
-- ----render :partial => "#{cell.partial}", :locals => {:item => cell.item}

In production, it takes 12 seconds to render 5000 rows
On the same machine, the oracle web interface renders 5000 of those same lines in 2 seconds.
That is 6 times faster.

What is the problem? Is it really that bad in rails, or am I just not understanding something?

We use slim, c haml speed is the same

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2012-01-21
@AndreyMorozov

You shoot sparrows from a cannon. Use partials to create a table... Isn't your task solved through helpers?

M
Maxim Lapshin, 2012-01-22
@erlyvideo

Start by removing all content_tags. If it does not help, then there are no easy ways to speed it up.

E
Envek, 2012-02-28
@Envek

If partials are small, then it makes sense (both in terms of speed and readability) to replace
_table.html.slim

render :partial => row, :collection => rows
_row.html.slim
render :partial => cell, :collection => cells

to something like
_table.html.slim
rows.each_with_index do |row, row_count|
  render :partial => cell, :collection => cells

Partials are good, but it's not worth it to produce a lot of them

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question