[LRUG] Recommendations for Ruby & Rails optimisation resources

Graham Ashton graham at effectif.com
Mon Nov 26 06:03:05 PST 2012


On 26 Nov 2012, at 13:52, Stephen Best <bestie at gmail.com> wrote:

> TL;DR
> 
> "The easiest way to optimize the server’s rendering of templates is to not have the server render the templates. We can do this by having by pushing rendering logic client-side..."

While it could be rendering, there's no evidence that it is. Rendering client side just causes a different performance problem.

If you've got that many rows of HTML in your table, you could just have some slow code inside a loop.

How many columns are in this table?

Is the data that is rendered in each table cell pre-calculatd by the database, or are you performing some manipulations to it (in Ruby) before/during the rendering of the table?

If you've got nested loops that might explain it. I was once in a situation where we were rendering a 1000 row table with about 5 columns in it. The code that rendered one of those columns had been written to derive its value from all the other rows in the table. Net result; 1,000,000 calls to Hash#fetch. Refactoring to pre-calculate all the data before trying to render the table made it blazing fast.

We found it by using a profiler. Highly recommended; then you can stop guessing.

--
Graham Ashton
Founder, The Agile Planner
http://www.theagileplanner.com | @agileplanner | @grahamashton




More information about the Chat mailing list