Blackfire: first impressions

Beginning of August, the friendly people of SensioLabs gave our team a demo of, their new and shiny PHP profiler. Sensio's @fabpot himself took an hour to give us a nice overview of what Blackfire can do. After the demo, we all felt very excited and my fingers itched to test-drive Blackfire on one of our bigger projects. Here are my first impressions.


One thing the Blackfire team immediately got right, is the documentation. The installation process is well described in the docs and it really was a breeze. All server configuration of the project is written in Ansible and in a matter of minutes, Blackfire was added to the provisioning and my dev box was ready.

Blackfire essentially works in a client-server configuration. A Blackfire-agent is running on your server and each time you profile, data is sent to, where you can see it in your site profile. One of my concerns is this central role of a server that is not under our control. Fabien ensured us no sensitive data is stored on their system, and in fact you could verify this by keeping a proxy between the agent(s) and server. For now, I will take Fabien's word for it.

When configuring the Blackfire-agent, one of the settings is collector= This makes me hopeful that maybe one day we will be able to run our own collector to keep track of our own data.


Once you have Blackfire running, there are multiple ways of profiling your code. The easiest is by installing the Blackfire Companion Chrome Extension. When installed, you can log in to your account, and from then on you can profile all the URL's you have access to by clicking a button in your browser.

This is a major difference with XHProf: Blackfire can be enabled on your server, but you have to explicitly initiate a profile request. XHProf can automatically profile all request, or you could implement a sampling algorithm to for instance profile every 1000th request. This sort of functionality should eventually find its way to Blackfire though, no worries.

It's also possible to trigger profiles from the command line by using the blackfire cli utility that comes with the agent. In fact, if you want to profile a POST request, the cli utility is the only way of doing that. Just run blackfire curl -X POST to simulate this. Profiling cli scripts can be done with blackfire run <script>. So much easier than having to add some lines to your code to get a profile in xhprof!

First impressions

Over the years I've had my fair share of profiling, mostly with XHProf. So when trying out Blackfire, I compared to XHProf quite a lot. Here's a short list of things what I encountered during testing:

  • Blackfire is well integrated into the SensioLabs eco-system. One account gives us access to all things SensioLabs, which is nice and easy.
  • Profiling a URL is made easy with the Chrome Extension. Profiling CLI scripts and SQL queries is also effortless. XHProf just can't beat that.
  • The central role for the site wories me a bit. Not only because of the data transmitted to them, but also because it's not probably not possible to profile your application if their server is down. We're now in the age of subscription-based services, so it's understandable. But sometimes having things run stand-alone isn't so bad either.
  • The UI is very polished and slick. When compared to standard XHProf (forget XHGui for a minute), its much more pleasing to the eye. There is also a problem with that nice UI however: traveling up and down the call tree is more cumbersome than with the spartan XHProf UI. Parent or child call information is hidden behind at least one extra layer of clicks. These extra clicks made if more difficult for me to navigate to a bottleneck.
  • There are some nice features in the UI, like giving a profile run a name; comparing 2 profile runs is dead easy; creating references; ...
  • The Agent can output JSON data, which you could integrate in your CI setup. This is not possible with XHProf, AFAIK. Furthermore, SensioLabs is currently working on extra features like the recently released (Premium-only) Assertions so you can integrate Blackfire runs even further in your CI setup.
  • Blackfire tries to condense the amount of information so you're not overwhelmed by it. Just look at a callgraph from Blackfire and compare it to a callgraph from XHProf. The former looks much cleaner and easier to digest. Personally, I like my information. I like sifting through the profile data and clicking around to locate a bottleneck. When software is deciding which information is usefull and which isn't, I always have the feeling I am going to mis something. Adding an option to switch on/off condensing would be a nice feature!


During and after our personal demo of Blackfire, the team was quite impressed with what we'd seen. Now that I've had the chance to further test things out, I am pleased that the demo wasn't just some marketing demo. The tool worked as well as the demo showed us. After years of using XHProf, I will have to get used to a different tool for performance testing. So in the future, I will keep using Blackfire for profiling. But when I'm unable to find the bottlenecks, chances are that I will still be firing up good old XHProf to compare the results with.