TLDR:
When Xdebug is loaded as a PHP module, it takes a heavy performance toll even when completely disabled. [1]
Is it possible to load Xdebug module without ANY performance overhead?
Considering, of course, that it HAS a performance overhead when it's actively debugging (through the presence of a debug cookie in HTTP requests, or, in CLI, through a series of -dxdebug
parameters to enable it) or while profiling.
Full explanation:
I was investigating poor performance issues when running an integration test suite. It was taking 2 minutes to run the whole suite. I had disabled everything there was to disable on Xdebug, until I finally decided to completely remove the module itself from PHP. When I did that, the integration suite took 56 seconds to run. Almost twice as fast.
I started digging into it and saw that this is a common issue. Again [1] as a reference. These are the settings that I'm using:
xdebug.remote_autostart = Off
xdebug.default_enable = Off
xdebug.profiler_enable_trigger = Off
xdebug.remote_enable = Off
xdebug.remote_handler = dbgp
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
xdebug.remote_log = /var/log/php/xdebug.log
And this is the PHP / Xdebug version:
PHP 7.4.2 (cli) (built: Feb 1 2020 19:47:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.2, Copyright (c), by Zend Technologies
with Xdebug v2.9.2, Copyright (c) 2002-2020, by Derick Rethans
I saw this difference in PHP CLI.
[1] Related:
- https://bugs.xdebug.org/view.php?id=1668 (Some guy opened a bug report for this a few months ago, but it seems that the Xdebug dev marked this as a non-issue)
- https://www.frankmayer.info/blog/12-xdebug-disabling-vs-not-loading-it-at-all
- https://stackoverflow.com/a/53399683/2056484