Visualizing existing XHProf and Callgrind Profiles

By Fabien Potencier, on Jan 21, 2015
This feature is deprecated as of March 2021.

When profiling some code, Blackfire stores a bunch of data in a specific format that encompasses a lot of information about time, memory, and some metadata as well. The Blackfire format is interesting in itself (and inspired by XHProf) but I will blog about it in a future post.

Blackfire is not the only profiler in the PHP world, and you’ve probably already heard of existing Open-Source ones like XHProf, UProfiler, which is really just an up-to-date fork of XHProf, and Xdebug. XHProf uses a simple but very PHP-oriented format: data are stored in a PHP array and serialized via the PHP serialize() function. Xdebug uses the more common and standard Callgrind format; the Callgrind format is used by many profilers and one of the best visualization tools is KCachegrind (with ports for non-Linux platforms).

For the past few months, you’ve been able to use as an alternative frontend for XHprof and Xdebug profiles by uploading them via our web interface. But it was impractical and of limited-use as such profiles can be really huge even for a few lines of code (several Gigabytes).

The web uploading feature has just been disabled and replaced with a much better alternative: ablackfire upload CLI command (you need to upgrade Blackfire to version 0.20.0 to benefit from this new feature).

Using the new upload command is as easy as it can get: pass it a profile file name (containing a profile in the Blackfire, XHProf, or Callgrind format) and it will take care of everything:

$ blackfire upload profile.pprof

Like for any other Blackfire commands (like run and curl), you can also pass a slot number to make the command non-interactive (note that options must be placed before upload):

$ blackfire --slot=upload profile.pprof

Before uploading the file to our platform, Blackfire first optimizes the data into a much smaller representation (on average, it compresses the profile by a factor of 1000 for Callgrind profiles); so feel free to feed it with your biggest profiles.

You can even ask Blackfire to aggregate several files into one:

$ blackfire upload profile1.pprof profile2.pprof profile3.pprof ...

There is one more thing: if you are still on PHP 5.2, you can still use Blackfire via XHProf and Xdebug… but of course, try to migrate to modern PHP versions as soon as possible.

If you are using XHprof, Xdebug, or any other tools that is able to generate a Callgind output, you can use Blackfire as a frontend thanks to the new Blackfire upload command. And as you might have realized now, this is the first step towards supporting more than PHP in Blackfire.

Stay tuned and happy profiling!

Fabien Potencier

Fabien Potencier is the CEO and founder of He founded the Symfony project in 2004 as he constantly looked for better ways to build websites. Fabien is also the creator of several other Open-Source projects, a writer, a blogger, a speaker at international conferences, and the happy father of two wonderful kids.