Blackfire performance profiling

Now nearly a year ago I was put on new task:

Optimize the performance of an application I did not know before.
This was not a really a new tasks for me, but I was a little worried about the available tools outside. They work, but it is mostly hard to find the performance issue.
During this time Blackfire was already in beta and in the end of November a colleague and me got access. So I tried the same also with Blackfire. In the end I could not find anything for this project. But I really liked Blackfire.

Some month later I started to profile the performance of the homepage of a different project. Here I could very quickly find some issues and within one day I was able to double the performance of the homepage. To bad that I don’t have those profiles anymore.

On my current project we are mostly serving an API for mobile devices. So I took one day to profile every API endpoint. First I could not find any specific, but after I added 20.000 test items (and also over 6000 items are related to my test user) the performance of one Endpoint dropped to around 3.x seconds.

Here is to bad profile for the endpoint:
(note: screenshot say 18s but during this time the importer was still running)

Spot (what you can see in the screenshot) is the small ORM we use in our project. I quickly realized that there where 6426 entities created – which is definitely wrong :).

The issue was quickly found. All related items where fetched and counted (picardpalm) instead of using a real count query. So the fix for this issue was also very quick:

The result with the next profiling:

208ms instead of 3.x seconds.

The direct comparison:

Without Blackfire and the testdata we would not have found this problem until someone hits the amount of items which could took some month.

If you did not worked with Blackfire: Try it out. Its really worth the time you invest. And it offers much more I just described here.