Page MenuHomePhabricator

Disable xdebug for phpunit/composer unless needed
Closed, ResolvedPublic

Description

Looks like xdebug slow down composer/phpunit quite a bit. I noticed that when comparing:

mwext-Wikibase-repo-tests-sqlite-php55-trusty
mwext-Wikibase-repo-tests-sqlite-php55-jessie

trusty:

PHP 5.5.9-1ubuntu4.21 (cli) (built: Feb  9 2017 20:54:58)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

Time: 2.6 minutes, Memory: 1341.50MB

jessie:

PHP 5.5.38-4+wmf1+jessie (cli) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

Time: 1.15 minutes, Memory: 1306.25MB

When installing the Debian package php-xdebug, it adds an ini file for the cli as /etc/php5/cli/conf.d/20-xdebug.ini. We should drop that file and when we do need xdebug, we can explicitly enabled it via php -d extension=xdebug.so.

Event Timeline

In https://gerrit.wikimedia.org/r/#/c/382939/ I installed php-xdebug in the base php package, but disabled it by default with phpdismod xdebug. Images that inherit from that one can either re-enable it by default with phpenmod xdebug (as composer-package image does) or they can run a command with php -d extension=xdebug.so.

Change 397778 had a related patch set uploaded (by Hashar; owner: Hashar):
[integration/config@master] Ensure xdebug.so is loaded for phpunit coverage

https://gerrit.wikimedia.org/r/397778

Change 397778 merged by jenkins-bot:
[integration/config@master] Ensure xdebug.so is loaded for phpunit coverage

https://gerrit.wikimedia.org/r/397778

Change 397787 had a related patch set uploaded (by Hashar; owner: Hashar):
[operations/puppet@production] contint: disable XDebug by default

https://gerrit.wikimedia.org/r/397787

From T178701, composer-package-php70-docker has XDebug enabled.

The jobs running HHVM or Zend 5.5 do not have XDebug.

For the others (Zend 5.6, Zend 7.0), one would potentially be able to enable the extension via:

php -d zend_extension=xdebug.so

What if we had our php wrapper script automatically add -d zend_extension=xdebug.so if PHP_USE_XDEBUG env variable is true?

Also having xdebug enabled is not a problem for composer anymore, it has some really scary magic that causes it to restart itself with xdebug disabled: https://github.com/composer/composer/blob/master/src/Composer/XdebugHandler.php

Change 397787 merged by Dzahn:
[operations/puppet@production] contint: disable XDebug by default

https://gerrit.wikimedia.org/r/397787

hashar claimed this task.

On a Jessie instance:

$ for v in 5 5.5 5.6 7.0; do echo "== PHP v$v =="; /usr/bin/php$v -m|grep -i xdebug; done;
== PHP v5 ==
PHP Deprecated:  Comments starting with '#' are deprecated in /etc/php5/cli/conf.d/20-xhprof.ini on line 2 in Unknown on line 0
== PHP v5.5 ==
== PHP v5.6 ==
== PHP v7.0 ==

/usr/bin/php5 was the only one still having xdebug.