View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001668 | Xdebug | Profiling | public | 2019-05-20 14:34 | 2020-12-12 05:54 |
Reporter | alforg | Assigned To | derick | ||
Priority | high | Severity | major | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Platform | x86_64 | OS | CentOS | OS Version | 7.6 |
Product Version | 2.6.1 | ||||
Summary | 0001668: Just installing xdebug slows php (both apache OR cli) down 6 to 12 x | ||||
Description | On a Centos 7.x machine, php7.3. The mere installation of xdebug has the effect described in subject. When installing, the file /etc/php.d/xdebug.ini is created, which loads libxdebug.so. However, all of xdebug debug and tracing functions are still disabled. The overhead incurred is dramatic, from 6 x up to almost two orders of magnitude, both in web AND CLI execution. strace-ing a CLI script shows an unordinate amount of time is spent syscalling getimeofday - so it may be related to profiling. This also happens on CentOS6, php56... | ||||
Steps To Reproduce | (1) Run the attached script. Record the output Actual slowdown is code dependent - 10-20 times is not uncommon for wordpress sites. | ||||
Tags | performance | ||||
Attached Files | bench.php (3,167 bytes)
<?php /* ########################################################################## # PHP Benchmark Performance Script # # � 2010 Code24 BV # # # # Author : Alessandro Torrisi # # Company : Code24 BV, The Netherlands # # Date : July 31, 2010 # # version : 1.0 # # License : Creative Commons CC-BY license # # Website : http://www.php-benchmark-script.com # # # ########################################################################## */ function test_Math($count = 140000) { $time_start = microtime(true); $mathFunctions = array("abs", "acos", "asin", "atan", "bindec", "floor", "exp", "sin", "tan", "pi", "is_finite", "is_nan", "sqrt"); foreach ($mathFunctions as $key => $function) { if (!function_exists($function)) unset($mathFunctions[$key]); } for ($i=0; $i < $count; $i++) { foreach ($mathFunctions as $function) { $r = call_user_func_array($function, array($i)); } } return number_format(microtime(true) - $time_start, 3); } function test_StringManipulation($count = 130000) { $time_start = microtime(true); $stringFunctions = array("addslashes", "chunk_split", "metaphone", "strip_tags", "md5", "sha1", "strtoupper", "strtolower", "strrev", "strlen", "soundex", "ord"); foreach ($stringFunctions as $key => $function) { if (!function_exists($function)) unset($stringFunctions[$key]); } $string = "the quick brown fox jumps over the lazy dog"; for ($i=0; $i < $count; $i++) { foreach ($stringFunctions as $function) { $r = call_user_func_array($function, array($string)); } } return number_format(microtime(true) - $time_start, 3); } function test_Loops($count = 19000000) { $time_start = microtime(true); for($i = 0; $i < $count; ++$i); $i = 0; while($i < $count) ++$i; return number_format(microtime(true) - $time_start, 3); } function test_IfElse($count = 9000000) { $time_start = microtime(true); for ($i=0; $i < $count; $i++) { if ($i == -1) { } elseif ($i == -2) { } else if ($i == -3) { } } return number_format(microtime(true) - $time_start, 3); } $total = 0; $functions = get_defined_functions(); $line = str_pad("-",38,"-"); echo "<pre>$line\n|".str_pad("PHP BENCHMARK SCRIPT",36," ",STR_PAD_BOTH)."|\n$line\nStart : ".date("Y-m-d H:i:s")."\nServer : {$_SERVER['SERVER_NAME']}@{$_SERVER['SERVER_ADDR']}\nPHP version : ".PHP_VERSION."\nPlatform : ".PHP_OS. "\n$line\n"; foreach ($functions['user'] as $user) { if (preg_match('/^test_/', $user)) { $total += $result = $user(); echo str_pad($user, 25) . " : " . $result ." sec.\n"; } } echo str_pad("-", 38, "-") . "\n" . str_pad("Total time:", 25) . " : " . $total ." sec.</pre>"; ?> | ||||
Operating System | |||||
PHP Version | 7.2.10-7.2.14 | ||||
|
A debugger does work, so that makes it slow down the request. The benchmark you provided is not representative of a real workload of PHP, and might give skewed results. I hope to address some of the performance impacts in Xdebug 3, but as there is no actionable point in this issue report, I am closing it. |
|
I agree that any debug code/extension will have a impact. What this issue points at, however, is that the its mere presence (module installed, unconfigured) slows down a site of amounts that can be above 10x. Slow downs of this magnitude are (in my experience) unexpected when not actively tracing/debugging the code. The benchmark is obviously a toy, but the effect is consistent with what can be witnessed on live sites. At the moment, I have been forced to nuke xdebug from all the servers under my company's administration (the production ones, at least). |
|
I urge you to re-open this issue. I've got 2x slower requests when Xdebug module is loaded but completely disabled. I've seen a lot of articles around the web talking about this, and I've confirmed this happens with my co-workers as well, in various PHP environments with Xdebug. I understand that a debugging tool will slow down requests, but I'd expect it doesn't impact a request that is not being debugged or profiled, especially if Xdebug is completely disabled, with all options "Off". Do you know where this performance degradation for the mere presence of Xdebug comes from? More information here: https://stackoverflow.com/questions/60985072/how-to-load-xdebug-module-into-php-without-performance-overhead |
|
Mostly fixed in 3.x version as per 0001872 |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-05-20 14:34 | alforg | New Issue | |
2019-05-20 14:34 | alforg | Tag Attached: performance | |
2019-05-20 14:34 | alforg | File Added: bench.php | |
2019-06-28 11:22 | derick | Assigned To | => derick |
2019-06-28 11:22 | derick | Status | new => resolved |
2019-06-28 11:22 | derick | Resolution | open => no change required |
2019-06-28 11:22 | derick | Note Added: 0005043 | |
2019-07-12 09:49 | alforg | Note Added: 0005057 | |
2020-04-03 22:42 | lucasbustamante | Note Added: 0005374 | |
2020-12-12 05:54 | weitzman | Note Added: 0005589 |