railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.89k stars 2.26k forks source link

Performance - fast ActiveRecord but slow 'Views' #2392

Open jbhewitt opened 9 years ago

jbhewitt commented 9 years ago

Not sure if this is the right place to ask this!

Hi all,

I'm trying to understand what's wrong here and if there is a way to speed up.

When I load up a rails_admin index for a query I'm getting the following:

  Rendered /home/dev/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/bundler/gems/rails_admin-dbff2cfba6e8/app/views/rails_admin/main/index.html.haml within layouts/rails_admin/application (1830.9ms)

  Rendered /home/dev/.rbenv/versions/2.1.6/lib/ruby/gems/2.1.0/bundler/gems/rails_admin-dbff2cfba6e8/app/views/layouts/rails_admin/_sidebar_navigation.html.haml (455.5ms)

  Completed 200 OK in 2411ms (Views: 2331.6ms | ActiveRecord: 16.4ms)

Is there extra logic happening in Views that I'm not aware of? I'm not sure where to start to try and speed things up. It's searching around 20k of records for a text query.

JB

simonc commented 9 years ago

Having the same issue but actually your lucky with a ~2sec time ^^

Completed 200 OK in 11711ms (Views: 11682.0ms | ActiveRecord: 1.3ms)

Is there something we can do to make it better?

gzcf commented 8 years ago

It's always slow in my experience. Now it throw 504 Time out because it is slower and consume horrible 173759ms.

I, [2016-07-09T12:08:39.392183 #10]  INFO -- : Started GET "/" for 111.196.66.14 at 2016-07-09 12:08:39 +0800
I, [2016-07-09T12:08:39.409836 #10]  INFO -- : Processing by RailsAdmin::MainController#dashboard as HTML
I, [2016-07-09T12:11:32.838041 #10]  INFO -- :   Rendered /var/lib/gems/2.1.0/gems/rails_admin-0.6.3views/rails_admin/main/dashboard.html.haml within layouts/rails_admin/application (665.6ms)
I, [2016-07-09T12:11:32.894939 #10]  INFO -- :   Rendered /var/lib/gems/2.1.0/gems/rails_admin-0.6.3views/layouts/rails_admin/_secondary_navigation.html.haml (1.7ms)
I, [2016-07-09T12:11:33.155430 #10]  INFO -- :   Rendered /var/lib/gems/2.1.0/gems/rails_admin-0.6.3views/layouts/rails_admin/pjax.html.haml (41.7ms)
I, [2016-07-09T12:11:33.168918 #10]  INFO -- : Completed 200 OK in 173759ms (Views: 996.9ms | ActiveRecord: 275.0ms)
NickNish09 commented 3 years ago

Any news on this one? Having the same problem:

Completed 200 OK in 56193ms (Views: 54958.1ms | ActiveRecord: 433.5ms)
NickNish09 commented 3 years ago

I have an update on this one. I had this problem with small memory machines running my rails app. It was running on a 512mb memory on each instance of my server. We updated to less instances of 1gb of memory each and the problem seem to be solved.

This could be a problem regarding memory consumption from rails admin, but I don`t know if this was just a coincidence or it was the problem

NickNish09 commented 3 years ago

Ok I have another update on this one.

In my case, not only rails admin was slow, but any static page (a view that rendered html). This was caused by this line on config/environments/production.rb:

config.assets.compile = true

This was compiling all assets on every page change. This was causing the slow views problem. I changed it to config.assets.compile = false and used rails assets:precompile and everything is back to normal

MrFehr commented 1 month ago

Just in case anybody needs a resolution for speed, installing the ArLazyPreload gem fixes all N+1 errors for RailsAdmin and makes it super fast.