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:
fl=/home/httpd/drupal-test/drupal-7.15/includes/cache.inc fn=_cache_get_object 22 68 cfl=/home/httpd/drupal-test/drupal-7.15/includes/bootstrap.inc cfn=variable_get calls=1 0 0 27 4 cfl=/home/httpd/drupal-test/drupal-7.15/includes/bootstrap.inc cfn=variable_get calls=1 0 0 29 2 cfl=/home/httpd/drupal-test/drupal-7.15/includes/cache.inc cfn=DrupalDatabaseCache->__construct calls=1 0 0 31 5
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:
fl=(4) fn=(53) _cache_get_object 22 80 cfl=(2) cfn=(45) calls=1 0 0 27 4 cfl=(2) cfn=(45) calls=1 0 0 29 3 cfl=(4) cfn=(52) calls=1 0 0 31 5
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.
Other parts in this series:
Life Line
We're about to celebrate the most famous Scottish poet!
Created a waste_basket
Created 2 waste_baskets
Created a bench
Created 4 benches
Created a waste_basket and a bench; Updated a toilet
Created a bench
Created an information
Updated a restaurant
Created 2 grit_bins
Created 2 waste_baskets
I hiked 20.5km in 3h52m17s
Updated a post_box
I walked 3.9km in 38m24s
I walked 5.0km in 47m13s
Merge branch 'xdebug_3_5'
Merged pull request #1060
Style fixes, and make log message type and text consistent
Fixed issue #2395: Change Windows Named Pipe control socket implement…
I walked 8.2km in 1h26m27s
I walked 1.2km in 9m48s
I've just finished reading "Children of Ruin", by Adrian Tchaikovsky.
The second book in the series, following Children of Time (the one with the spiders).
Great read, but a little creepy at times.
I walked 8.4km in 1h21m38s
Merged pull request #1061




Shortlink
This article has a short URL available: https://drck.me/profilecomp23-bp6