[LRUG] Recommendations for Ruby & Rails optimisation resources

Alan Buxton alanbuxton at gmail.com
Fri Nov 23 06:44:20 PST 2012


Ref ERB vs HAML: in about May 2011 we replaced a lot of haml with erb
because it was faster in our use case. We did some proof of concept work
first to see if there was a difference and saw a speedup in view rendering
of 10 - 20%. So "measurably" faster but not "orders of magnitude" faster. We
decided it was worthwhile to do, but we knew it wasn't going to make a
dramatic difference on its own. And bear in mind this was all a long time
ago and I wouldn't normally take stats from 18 months ago too seriously
today. 

 

a

 

 

From: chat-bounces at lists.lrug.org [mailto:chat-bounces at lists.lrug.org] On
Behalf Of Riccardo Tacconi
Sent: 23 November 2012 12:37
To: Frederick Cheung
Cc: London Ruby Users Group
Subject: Re: [LRUG] Recommendations for Ruby & Rails optimisation resources

 

Hi,

 

To understand where the bottleneck is you have to profile your app. 

 

To improve your DB performance you could check if there are new versions of
your DBMS. For instance MySql 5.5 is faster the 5.1. You could use memcached
to reduce DB access time. Are you searching data using the DB or do you use
Sphinx or Elastic Search? By moving your queries to a search engine you will
remove the load from you DB and your searches will be faster.

 

I do not know if ERB is faster than HAML but I think you should choose the
one you are more confortable to develop with. I prefer HAML because it makes
my views cleaner than ERB.

 

Selecting only the columns you need will make your app a bit faster, not
sure how much, you should see it  from a profilers' report.

On 23 November 2012 13:17, Frederick Cheung <frederick.cheung at gmail.com>
wrote:

Have you profiled your code?

Initialisation of active record objects does definitely take time, so
dropping down to select_all will save you some cycles, and obviously not
fetching columns from the DB will help too. Without profiling you won't know
whether that's the hot spot though.

Fred


On 23 Nov 2012, at 12:14, Jonathon Horsman <jonathon at arctickiwi.com> wrote:

> Hi
>
> I need to improve the performance of a particular Rails action.
>
> I'm using fragment caching which is helping a lot, but the initial cache
generation is still in the order of 5 seconds.
>
> So I'm looking into the garbage collector, this article provided some
hints but no suggestions:
http://merbist.com/2010/07/29/object-allocation-why-you-should-care/
>
> e.g. how do I reduce the amount of object allocation in Rails? Should I be
using the select() method in ActiveRecord to reduce initialized fields?
> Is it better to use select_all and work directly with hashes?
>
> Is HAML markedly slower than ERB? The view generation seems to take the
majority of time.
>
> I'd really appreciate any tips or links to articles.
>
> Many thanks
>
> --
> Jonathon Horsman
> Director
> Arctic Kiwi
> Mobile: 079 42366038
> Web: http://www.arctickiwi.com
> Twitter: @jhorsman
>
>

> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org


_______________________________________________
Chat mailing list
Chat at lists.lrug.org
http://lists.lrug.org/listinfo.cgi/chat-lrug.org





 

-- 
Riccardo Tacconi
Ruby on Rails and PHP development - System Administration
VIRTUELOGIC LIMITED <http://virtuelogic.net/> 

http://github.com/rtacconi
http://riccardotacconi.blogspot.com
http://twitter.com/rtacconi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20121123/61825bd5/attachment-0003.html>


More information about the Chat mailing list