Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After enabling Xdebug PHP runs incredibly slowly

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?

like image 394
Goodnickoff Avatar asked Aug 07 '15 16:08

Goodnickoff


People also ask

Does XDebug slow PHP?

Yes, debuggers like XDebug reduce the performance of the PHP server. This is the reason why debuggers are not placed in server environment. They are deployed in a different environment to avoid unnecessary overheads.

How does PHP XDebug work?

When Xdebug is running, it will call back to your IDE (like PhpStorm or VS Code) from the server where it's running. Your IDE will sit and listen for that connection on a specific port (typically port 9000 or 9003).


1 Answers

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.

like image 153
Nathan F. Avatar answered Sep 30 '22 06:09

Nathan F.