Xdebug 2.3: Profiler File Compression

This is the seventh (and last) article in a series about new features in Xdebug 2.3, which was first released on February 22nd.

When you make profiling dumps with Xdebug, the file size can grow quite large. Even with a simple Drupal page a profile file is easily close to 1Mb.

For each function call, the file contains the location and name of the calling function, and then a list of functions that have been called. For example, the following snippet shows that the _cache_get_object function in /home/httpd/drupal-test/drupal-7.15/includes/cache.inc calls variable_get in /home/httpd/drupal-test/drupal-7.15/includes/bootstrap.inc twice, and DrupalDatabaseCache->__construct once:

In those 15 lines, you can already spot a lot of duplicated information. The Callgrind Profile Format which Xdebug uses for writing profiling information allows for Name Compression. This allows a write, such as Xdebug, to simple refer to longer strings by a number. This number is assigned the first time a certain file name or function name is encountered. The above snippet, from the same request of a Drupal site, with Name Compression enabled now looks like:

Every file name and function name, except for _cache_get_object has been previously defined, and hence, is not repeated in its entirety, but just by its identifier. This sort of compression makes the profiling files a lot smaller. In this case, my simple-Drupal-profiling file went down from 926Kb to 385Kb.