Random rails are 100 times slower than expected

I have a rather large representation of the answer, broken into partial, the structure of which looks like where * indicates that this partial is loaded more than once:

show
-responses
--response*
---comments
----comment*
---comment_form
-stats

My problem is that, depending on the page size, most of these partitions take 10-20 ms for rendering, however a couple of these scores takes 800-1000 ms for rendering. It seems that there is no template in which it exists, that is, the same if I update quickly and often not.

+4
source share
1 answer

Use first

<%= render partial: 'partial', collection: @collection, as: c %>

but not

 <% @collection.each do |c| %> <%= render partial: 'partial', locals: { c: c } %> <% end %> 

This is obvious, I donโ€™t know why I didnโ€™t. They brought some improvements, but not a huge amount.

If you use 1.9.3, these environment variables are of great importance, knocking down about 20% of the request:

 RUBY_HEAP_MIN_SLOTS=600000 # This is 60(!) times larger than default RUBY_GC_MALLOC_LIMIT=59000000 # This is 7 times larger than default RUBY_HEAP_FREE_MIN=100000 # This is 24 times larger than default 

via: http://www.web-l.nl/posts/15-tuning-ruby-s-garbage-collector-with-rvm-and-passenger

0
source

All Articles