# Engines 1.2 and performance

**URL:** <https://www.ruby-forum.com/t/engines-1-2-and-performance/87728>\
**Category:** Engines\
**Created:** [March 5, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/engines-1-2-and-performance/87728 "2007-03-05T16:40:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [March 5, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/engines-1-2-and-performance/87728/1 "2007-03-05T16:40:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [March 5, 2007, 5:38pm UTC](https://www.ruby-forum.com/t/engines-1-2-and-performance/87728/2 "2007-03-05T17:38:10Z")

</div>

On 3/5/07, Henry [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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…

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [March 5, 2007, 8:23pm UTC](https://www.ruby-forum.com/t/engines-1-2-and-performance/87728/3 "2007-03-05T20:23:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [March 5, 2007, 11:54pm UTC](https://www.ruby-forum.com/t/engines-1-2-and-performance/87728/4 "2007-03-05T23:54:14Z")

</div>

Thanks, Eric. Great plugin!

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [March 5, 2007, 11:18pm UTC](https://www.ruby-forum.com/t/engines-1-2-and-performance/87728/5 "2007-03-05T23:18:08Z")

</div>

Henry P. 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:

> **[\[PLUGIN RELEASE\] - Browser Profiler](http://revolutiononrails.blogspot.com/2007/01/plugin-release-browser-profiler.html)**
>
> ================ =================== http://rubyforge.org/projects/browser-prof/ ================ =================== BrowserProfiler a quic...

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
