[xdebug-dev] [xdebug/xdebug] 3f59db: Fixed issue #1096: performance improvement handlin...

From: Derick Rethans <github[@]derickrethans.nl>
Date: Tue, 23 Dec 2014 13:58:45 -0800

  Branch: refs/heads/master
  Home: https://github.com/xdebug/xdebug
  Commit: 3f59db18d490bcfc4cdfe5424ee2e966d00e0cb1
  Author: Daniel Sloof <goapsychadelic[@]gmail.com>
  Date: 2014-12-23 (Tue, 23 Dec 2014)

  Changed paths:
    M xdebug.c

  Log Message:
  Fixed issue #1096: performance improvement handling breakpoints

An earlier commit, 6c72559be41eeec065f5ff858e15d49236526fe7,
made sure that xdebug_sprintf always works with C locale. To do this,
it calls setlocale 3 times to:

- Grab the original locale.
- Set the locale to C.
- Restore the original locale.

One of the functions that calls into xdebug_sprintf is handle_breakpoints,
which can be called many times when dealing with a large codebase. In the
case of Magento 2, when preprocessing LESS files, this eventually caused
a single request to call setlocale over 8 million times. The relevant
(k)cachegrind profile can be viewed here:


Since this particular xdebug_sprintf call doesn't change depending on
locales (it just appends a class and a function), we can simply use
snprintf in this case.

The result is pretty significant:
Before: 51,74s user 0,56s system 98% cpu 52,948 total
After: 31,57s user 0,28s system 98% cpu 32,334 total

  Commit: 36e60220aa797458d9839482be3b2e0e9827e7d0
  Author: Derick Rethans <github[@]derickrethans.nl>
  Date: 2014-12-23 (Tue, 23 Dec 2014)

  Changed paths:
    M xdebug.c

  Log Message:
  Merged pull request #138

Compare: https://github.com/xdebug/xdebug/compare/6d2db2dd7311...36e60220aa79
Received on Tue Dec 23 2014 - 21:58:51 GMT

This archive was generated by hypermail 2.2.0 : Sun Jun 24 2018 - 04:00:03 BST