Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Increased loading times on Rails 3 compared to 2.3.8

#5079

Hi,

I bumped one of my apps to 3.0.0.beta4 and noticed the loading times have doubled.
On a very simple controller with a very basic view I get this loading time in development:

Completed 200 OK in 636ms (Views: 45.1ms | ActiveRecord: 2.9ms)

On 2.3.8 that was between 250ms and 300ms.

I can't see where to work on to improve this:

Started GET "/portfolio" for 127.0.0.1 at Fri Jul 09 15:12:26 +0200 2010
  Site Load (0.4ms)  SELECT `sites`.* FROM `sites` WHERE (`sites`.`subdomain` = 'major') LIMIT 1
  Processing by PortfoliosController#show as HTML
  User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1
  Theme Load (0.4ms)  SELECT `themes`.* FROM `themes` WHERE (`themes`.site_id = 1) LIMIT 1
  SQL (0.7ms)  SHOW TABLES
  Portfolio Load (0.5ms)  SELECT `pages`.* FROM `pages` WHERE (`pages`.`type` = 'Portfolio') AND (`pages`.site_id = 1) ORDER BY position ASC LIMIT 1
  Page Load (0.4ms)  SELECT `pages`.* FROM `pages` WHERE (`pages`.parent_id = 1) ORDER BY position ASC LIMIT 0, 15
  Page Load (0.5ms)  SELECT `pages`.* FROM `pages` WHERE (`pages`.parent_id = 1) AND (`pages`.`type` = 'Project') ORDER BY position ASC
Rendered layouts/_top_bar.html.haml (5.9ms)
Rendered layouts/_informer.html.haml (1.3ms)
Rendered portfolios/show.html.haml within layouts/admin (42.7ms)
Completed 200 OK in 636ms (Views: 45.1ms | ActiveRecord: 2.9ms)

Switching from WEBrick to mongrel gave me some better results but the numbers mentioned are already mongrel.

Edited by Rohit Arondekar for formating.

Reported by wout · July 9th, 2010 @ 02:21 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • Importance changed from to Low

    A lot of performance work has gone on since the release of beta4 - can you check against edge rails?

    July 9th, 2010 @ 03:24 PM

  2. wout
    wout

    Same view on edge:

    Completed 200 OK in 527ms (Views: 47.5ms | ActiveRecord: 2.8ms)

    Definitely better but still twice as much as on 2.3.8.
    Maybe it's too early to make these kind of evaluations...

    July 9th, 2010 @ 04:02 PM

  3. drjoke
    drjoke

    wout I think we are in the same boat. Can you please try this?

    puts Benchmark.measure{5000.times{User.find :first, :conditions => ["id = ?", (rand * 1000 + 1).to_i]}}
    

    Replace User with your favorite model and 1000 with the max number of rows you probably have for that model.

    Please try this in console for both 2.3.8 and 3.0 and report back the results.

    It would be great if you can also try this in production.

    I also have a ticket here: https://rails.lighthouseapp.com/projects/8994/tickets/5098-rails-3-...

    July 12th, 2010 @ 05:57 PM

  4. wout
    wout
    • Tag set to loading time

    Hi Moodang,

    The app I converted is not in production yet, but I tested on my local development machine in both development and production. I used my Page class since that's the most complicated table.

    puts Benchmark.measure{5000.times{Page.find :first, :conditions => ["id = ?", (rand * 1000 + 1).to_i]}}
    

    Rails 2.3.8

    development
    2.370000   0.260000   2.630000 (  3.294963)
    
    production
    2.220000   0.220000   2.440000 (  3.001813)
    

    Rails 3.0.0.beta4

    development
    6.110000   0.330000   6.440000 (  7.201925)
    
    production:
    6.380000   0.420000   6.800000 (  7.511156)
    

    In Rails 3 production is actually slower...
    I ran each benchmark 5 times and picked the most average result.

    Tested on:
    - 2.53GHz MacBook Pro with osx 10.6.4 and 4GB ram - Latest release of ruby EE 1.8.7 - Mongrel - Latest version of MySQL

    July 12th, 2010 @ 06:41 PM

  5. Daniel Guettler
    Daniel Guettler

    Just to chime in here. Here are my results for Rails 2.x and Rails 3.x for both Ruby 1.8.7 and 1.9.1

    
    Rails 2 & Ruby 1.8.7
    ==============================================================
    Loading production environment (Rails 2.3.5)
    >> puts Benchmark.measure{5000.times{User.find :first, :conditions => ["id = ?", (rand * 1000 + 1).to_s]}}
      1.580000   0.140000   1.720000 (  1.755681)
    
    Rails 2 & Ruby 1.9.1
    Loading production environment (Rails 2.3.5)
    >> puts Benchmark.measure{5000.times{User.find :first, :conditions => ["id = ?", (rand * 1000 + 1).to_i]}}
      1.160000   0.100000   1.260000 (  1.498934)
    
    Rails 3 & Ruby 1.8.7
    ==============================================================
    Loading production environment (Rails 3.0.0.beta4)
    irb(main):001:0> puts Benchmark.measure{5000.times{User.find :first, :conditions => ["id = ?", (rand * 1000 + 1).to_i]}}
      6.200000   0.270000   6.470000 (  6.666850)
    
    Rails 3 & Ruby 1.9.1
    ==============================================================
    Loading production environment (Rails 3.0.0.beta4)
    irb(main):001:0> puts Benchmark.measure{5000.times{User.find :first, :conditions => ["id = ?", (rand * 1000 + 1).to_i]}}
      2.570000   0.110000   2.680000 (  2.710209)
    
    Rails Edge & Ruby 1.9.1
    ==============================================================
    Loading production environment (Rails 3.0.0.beta4)
    irb(main):001:0> puts Benchmark.measure{5000.times{User.find :first, :conditions => ["id = ?", (rand * 1000 + 1).to_s]}}
      2.120000   0.140000   2.260000 (  2.408399)
    

    Is there a good way how you can do git bisect over multiple rails version? Obviously the setup etc of the application and dependent gems changes quite a bit between Rails 2.x and Rails 3.

    Thanks, Daniel

    July 12th, 2010 @ 08:17 PM

  6. wout
    wout

    I installed ruby 1.9.2rc1 and the app is nearly back to normal loading times.
    This is ruby 1.8.7:

    Completed 200 OK in 1468ms (Views: 776.6ms | ActiveRecord: 1.7ms)
    

    Same app, same view, same machine but ruby 1.9.2:

    Completed 200 OK in 525ms (Views: 298.6ms | ActiveRecord: 1.7ms)
    

    A lot of time is lost on the views, and still 525ms is rather high.
    But I can work with this, we need to go in production beta next month.

    July 17th, 2010 @ 02:24 PM

  7. wout
    wout

    Hi,

    Just wanted to let you know we went in production last week and loading times are blazingly fast (http://paspartout.com). New relic gives us 72ms average response time, which is about 10 times faster than the rails 3 beta tests we were concerned about. Great job!

    Wout

    September 27th, 2010 @ 10:32 PM

  8. Santiago Pastorino
    Santiago Pastorino

    wout, and in comparison with 2.3?.
    This ticket can be closed so?

    September 28th, 2010 @ 08:53 PM

  9. wout
    wout

    I can't really compare to 2.3.
    In fact I started building this project with 2.3 but than switched development to 3.

    I noticed the performance drawback so I opened this ticket.
    So comparing isn'r really possible.

    I have another similar app running in 2.3.8 and the average loading time is 253ms
    But paspartout (rails 3) runs on an 8-core Intel i7 with 8GB ram, the other app runs on a dual core AMD with 4GB ram, so I have no idea how that compares.

    September 28th, 2010 @ 09:09 PM

  10. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to resolved

    Ok so i'm closing it if you find some issue related with performance again please open another ticket :). Thanks.

    September 28th, 2010 @ 09:40 PM