Over the past couple of weeks I’ve been working with Adrian Ritchie from the recently formed Kodo Ltd. I’ve known Adrian for years and since he’s just started out on his own here in Guernsey and my own schedule was a bit hectic, I gave him a call to come take a look at an interesting problem.… it may surprise some that we did more than sit around drinking strong Brazilian coffee too.
Enrapture has been working on a large long-term project and one of the tasks involved the refactoring of some old code to help improve performance as it had been added to considerably over the years and was a tiny bit bloated. It took a day to do but the results of these efforts have been astounding.
The big improvement was to a part of the application that ran a loop of database queries. As the dataset has grown, the number of loops grew too and there were over 500 calls being made to the database. It was running so slowly that it needed to be sorted out.
Using the Blackfire.io profiler, we were able to look into the code as it ran and see exactly where the bottlenecks were. By visualising the problem, it is much easier to target the lines of code causing the problem in order to refine them into something more efficient. With Adrian’s rejig of things, the final profile showed a 93% reduction in time, a 78% reduction in CPU usage and 1MB saving in RAM used.
The Blackfire service proved very useful in this situation and I’m sure it will do so again. Another service we used was Cloud9 (c9.io) an online IDE. I never thought using one would be particularly great but I’ve been really impressed with it… think this could be another blog post.
Just to recap, go check out Blackfire and give it a try especially as it is currently free to try out.