Michael Koziarski : Optimising Rails

“programmers inclination optimising” is remark from Micheal in the same manner with he opens up his sitting. This is very true for all of us, we keep wanting to improve or apps, concentrating on making them run faster and being more efficient. In this session Micheal places some light-hearted attached things that we need to look before we blame Rails for making our apps slower.

He mentions that the objective for a programmer is to make a program run faster. it is science based, that a program runs x% faster.

The interesting question is “should businesses” focus on this, do they need to improve their performance to increase productivity. For him as a core member they must ensure that the performance of rails increases the productivity.

He points out the following three important points that the problem when optimizing a framework, we need to ask ourselves the following questions 1) find out what is slow? 2)why is it slow? 3)make it faster,

One of the examples that he uses is using textiling and sanitizing in the index view when you call a request multiple times, rather paragraph it in the controller and call it only once.

Michael points out another error that programmers make when analyzing why it is slow and that is that they guess, “at no time guess because you are never right”.

He says that in optimizing a rails procedure we need to run a benchmark. Running it against another application that is popular amongst OpenSource software. Although there is no erect of wrong answer because all apps are different. He continues talking about benchmarks and says that they are vehemently because they don’t help everyone succeed to see the speed of your app.

He also says that we penury an app to act as a benchmark. Next he makes an decomposition on a simple “hello world” application. Apps can have a few disturbances such as dispatcher callbacks of 5%, incitement variable copying of 9%. If we want to optimise our apps the most the we can get out is to reduce the dispatcher callbacks to 1.3% and instance variable copying to 1%, but this is on a simple “hello universe” app, in the real world this will not absolutely break the thwart.

Michael states that Rails 2.1 is three times faster that 2.0.

Here are some of the points that Michael had mentioned in his talk that we should look at when we write an app to optimize its performance.

Manage your sessions to increase the make haste of your apps by using cookie store. Empty or unchanged sessions should not be sent back to the database, therefore managing this will increase the speed of you application. As suitably as instance fluctuating copying can make your app 1.2 – 1.5% slower.

He continues on explaining the following that cause apps to perform slower which is passage recognition and route generation. With road recognition, one resources added adds about 12 routes accordingly intriguing your routes will increase your app performance by 3 to 20 epochs depending on the size of your app. Another important thing that we must keep in mind is to neglect the routes that we don’t need to run can make your app about 5-10 % faster.

Another “culprit” as he calls it is alias_method_chain. As it is methods are unready and using alias_method_chains it will decrease the performance by means of 4-12% therefore a request has in continuance mean proportion of tens of thousands of method calls and as a result this decreases your apps literary work.

Some other features that you can lay upon to your app to greaten its performance is to apply caching. If you need to continuously call an image try not to use an such as a .png image but rather use a onepixel gif, he states that this will help speed up your app too workmanship it quicker to upload your images.

Michael concludes that Rails can always be faster but before pointing fingers at Rails we should first dissect our apps first and apply the features of benchmarking our apps, create a exemplification application to compare your application through. Don’t believe in microbenchmarkings. If you want to monitor your apps consummation, rebuke out the plugin from NewRelic which is a great tool to see to which place your app is slowing from a thin to a dense state.

Annalisa