6

I have installed Apache 2.4 and PHP 5.6 on my PC (with Windows 10).

After enabling Xdebug PHP runs 10 times(!) slower than without Xdebug.

This is php.ini config:

zend_extension = "php_xdebug-2.3.3-5.6-vc11-x86_64.dll"
xdebug.remote_autostart = 0
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = "C:\PHP\tmp"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_mode=req
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port=9000
xdebug.idekey=netbeans-xdebug
xdebug.trace_output_dir = "C:\PHP\tmp"
xdebug.auto_trace = 0
xdebug.var_display_max_depth = 3
xdebug.remote_connect_back = 0

I've made sure that profiler and autostart are disabled. Does anybody know what is the reason of such behavior?

icc97
  • 11,395
  • 8
  • 76
  • 90
Goodnickoff
  • 2,267
  • 1
  • 15
  • 14
  • 2
    That's normal. I think – Ismael Miguel Aug 07 '15 at 16:29
  • This is only normal if you have **Lots of errors in your code**. So check the php error log, especially if you have stopped PHP displaying errors to the screen. I bet you find a mountain of errors – RiggsFolly Aug 07 '15 at 16:33
  • It's odd that it's slowing it down that much when xdebug is disabled, though. I've definitely seen that much slowdown with xdebug enabled in function- or object-heavy code, but I wouldn't expect that kind of slowdown with it disabled. – Ben Claar Aug 07 '15 at 16:33
  • This in not normal because I have not seen such issue on Linux and Windows 7. On these systems xdebug slows php not more than 2 times. – Goodnickoff Aug 07 '15 at 17:05
  • 1
    I have the same issue after updating to PHP 5.6 (Win 8.1) – Tomáš Fejfar Oct 30 '15 at 13:17

1 Answers1

1

Source: https://www.phase2technology.com/blog/profiling-production-whats-slowing-you-down

Instrumentation in interpreted languages, like PHP and Javascript, involves hooking into the runtime and explicitly collecting information about every function call as is occurs. This allows you to view the elapsed time spent, a call graph of function calls in the stack, memory and CPU stats, and other system data about your code as it executes on each request. Instrumented profiling does add overhead however, and it can be significant; this depends on the complexity of your application. This makes instrumented profiling ideal for development and debugging sessions, but limited for ongoing production analysis and monitoring.

A good alternative to instrumentation is sample-based profiling.

Sample-based profiling involves taking snapshots of an application at fixed intervals. Each snapshot records the currently-executed function(s), and the aggregate of these snapshots is used to approximate when and where time is being spent in your code. This provides much less detail than instrumented profiling but without the significant added overhead, making it ideal for production use.

Look at sample_prof for an example of sample-based profiling with PHP.

Nathan F.
  • 3,250
  • 3
  • 35
  • 69