Vadorequest Vadorequest - 6 months ago 3x
PHP Question

Php slower with XDebug activated but no debug session running

I just run into a weird issue. Maybe a XDebug issue.

I just configured XDebug for the first time in my dev environment, it works okay,I use PhpStorm and the integrated IDE to test my code, it's fine.

The problem is actually when I don't use the debug mode, for instance, if I start to debug and then I stop the debug process then my PHP script will get slower, around 5/8 seconds to display a hello word. (but with some logic behind) while it takes less than one second with the debug mode running.


zend_extension = "c:\wamp\bin\php\php5.4.12\ext\php_xdebug-2.2.3-5.4-vc9-x86_64.dll"

xdebug.remote_autostart = 0
xdebug.remote_enable = 1
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "c:/wamp/tmp"

I set autostart to false to avoid latency while I'm not using the XDebug mode. But once I started it I need to be in debug mode to use the "fast mode".

Any idea why?

I read some topics like Will enabling XDebug on a production server make PHP slower? and one of the answer seems to be about that.

I made some tests just enabling the module, without actually debugging, makes slows down a request on my development machine from 1 second to around 4 seconds


Its likely your profiler,

xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = off

From the manual

Type: integer, Default value: 0
When this setting is set to 1, you can trigger the generation of profiler files by using the XDEBUG_PROFILE GET/POST parameter, or set a cookie with the name XDEBUG_PROFILE. This will then write the profiler data to defined directory. In order to prevent the profiler to generate profile files for each request, you need to set xdebug.profiler_enable to 0.

So its always making profiles, Which will take much longer, You should only need to profile when you need to know the results of a profile

The debugger at most will try to open a socket. Its allows requests from GET POST and COOKIE. and when you connect, it sets a cookie for 1 hour by default which makes the debugger try and connect to a port each time you request after for 1 hour