Rails rendering processing has a 10x increase in time

Looking at ruby mini-profiler , I noticed that this 5-6 partial rendering template is about 6-7 ms each, and then one rendering in 60 to 70 ms. I was wondering what would cause this, it seems, is some kind of redness. All model data is loaded when rendering is started, so I know that this is not caused by lazy loading.

 Rendering: application/_row     7.1    +1107.0 
 Rendering: application/_row     68.7   +1115.0 
 Rendering: application/_row     6.7    +1184.0 
 ...     
 Rendering: application/_row     6.5    +1234.0 
 Rendering: application/_row     65.2   +1241.0 
 Rendering: application/_row     6.6    +1306.0 
 ...     
 Rendering: application/_row     6.6    +1321.0 
 Rendering: application/_row     66.6   +1328.0 
 Rendering: application/_row     6.6    +1395.0 
 ...     
 Rendering: application/_row     6.6    +1444.0 
 Rendering: application/_row     65.4   +1451.0 

Ruby 1.9.3p194, Rails 3.2.11

+5
source share
1 answer

This is the most specific MRI garbage collector that cleans memory. I did some testing with a simple Rails application and a partial one:

100.times{Test.new}

I could see the spikes just like you:

Rendered tests/_row.html.erb (3.9ms)
Rendered tests/_row.html.erb (45.3ms)
Rendered tests/_row.html.erb (5.2ms)
...
Rendered tests/_row.html.erb (42.8ms)

-, , GC , , . . 10 , 10 (+/- 1) GC, GC , .

GC -, ?pp=profile-gc-time URL-. Ruby -.

+5

All Articles