Forum: Rails Engines Engines 1.2 and performance

7aef4541a1355c993c66237b162d9681?d=identicon&s=25 Henry (Guest)
on 2007-03-05 16:40
Greetings,

We're running into some performance issues with an app and I'm hoping to
eliminate Engines as the cause before really taking things apart. Since
we updated the app to Rails v1.2 and upgraded three of the Engines to
plugins that use the 1.2 Engine plugin, we've noticed a noticeable slow
down in both development and staging (using production configuration)
environments.

The performance issue is manifested in page load times: 1-3 seconds now,
vs. fractions of a second in 1.6. Both development and production logs
show that the DB processing is around 5-10% of the page load and the
rendering about 80-90%.

The app has around 25 plugins total. In the development log I'm noticing
that each page render (or partial render via AJAX) causes the
Engines::RailsExtensions::Dependencies.require_or_load_with_engine_additions
method to fire, checking for controllers and helpers for each plugin.
Is this the expected behavior?  If so, is there a quick way to apply the
engines plugin only to the plugins I need it to instead of all 25?

Any insight/suggestions appreciated,

Henry
05d703f649ef1d07e78d7b479fb4c4ac?d=identicon&s=25 James Adam (Guest)
on 2007-03-05 17:38
(Received via mailing list)
On 3/5/07, Henry <hpoydar@gmail.com> wrote:
> Greetings,
>
> We're running into some performance issues with an app and I'm hoping to
> eliminate Engines as the cause before really taking things apart. Since
> we updated the app to Rails v1.2 and upgraded three of the Engines to
> plugins that use the 1.2 Engine plugin, we've noticed a noticeable slow
> down in both development and staging (using production configuration)
> environments.

If you're running without class reloading - i.e. with the production
configuration - you shouldn't see the engines plugin hitting the
plugins more than once, since once the class is loaded (via
require_or_load) it should never be required again. Do you get the
slowdown when running in production properly?

> The performance issue is manifested in page load times: 1-3 seconds now,
> vs. fractions of a second in 1.6. Both development and production logs
> show that the DB processing is around 5-10% of the page load and the
> rendering about 80-90%.

Depending on your queries, this could be normal... it's hard to say.

> The app has around 25 plugins total. In the development log I'm noticing
> that each page render (or partial render via AJAX) causes the
> Engines::RailsExtensions::Dependencies.require_or_load_with_engine_additions
> method to fire, checking for controllers and helpers for each plugin.
> Is this the expected behavior?  If so, is there a quick way to apply the
> engines plugin only to the plugins I need it to instead of all 25?

Again, require_or_load should *not* be called on each request in
production mode. It's normal for the engines code mixing mechanism to
check each plugin when loading classes (attempting to load
controllers/helpers from your_plugin/app/controller, etc), but this
shouldn't happen more than once in production. If, for some reason,
Rails is calling require_or_load for each request in production mode,
that seems like something wrong with Rails itself...
7aef4541a1355c993c66237b162d9681?d=identicon&s=25 Henry GP (henryp)
on 2007-03-05 20:23
(Received via mailing list)
Thanks for the response, James.   I did some testing in the
production environment and found that, indeed, require_or_load is
only fired on start up.   I'm going to investigate further with the
general assumption that the Engine plugin is not the bottleneck.

Thanks again for the Engine plugin, James.
5190330ad8f1b06d35e2c2da73dc623c?d=identicon&s=25 Eric Anderson (Guest)
on 2007-03-05 23:18
(Received via mailing list)
Henry Poydar wrote:
> only fired on start up.   I'm going to investigate further with the
> general assumption that the Engine plugin is not the bottleneck.

Something I have found to be VERY useful at debugging performance
problems in Rails is:

http://revolutiononrails.blogspot.com/2007/01/plug...

It uses ruby-prof (the ruby profiler written in C for fast results) to
profile your request. Simply append a querystring param and you get all
the gory details. It takes a bit of understand the results that
ruby-prof outputs (it's not like any profiler I have used) but once you
understand it you can find the exact place where the performance
problems exist.

Much more fine grain than Rails' 90% render, 10% database. :)

Eric
7aef4541a1355c993c66237b162d9681?d=identicon&s=25 Henry GP (henryp)
on 2007-03-05 23:54
(Received via mailing list)
Thanks, Eric.  Great plugin!
This topic is locked and can not be replied to.