diff --git a/Dockerfile b/Dockerfile index 0d49b3294..74aca7875 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,6 +98,11 @@ RUN set -eux; \ } > "$APACHE_CONFDIR/conf-available/mediawiki.conf"; \ a2enconf mediawiki +ARG INSTALL_PROFILING_DEPS=0 +ENV MW_ENABLE_PROFILING_HEADER=${INSTALL_PROFILING_DEPS} +COPY install_profiling.sh /install_profiling.sh +RUN if [ "$INSTALL_PROFILING_DEPS" = "1" ] ; then bash /install_profiling.sh ; else echo "skipping profiling dependencies ..." ; fi + ARG INSTALL_XDEBUG=0 COPY install_xdebug.sh /install_xdebug.sh RUN if [ "$INSTALL_XDEBUG" = "1" ] ; then bash /install_xdebug.sh ; else echo "skipping xdebug ..." ; fi diff --git a/dist-persist/wbstack/src/Settings/LocalSettings.php b/dist-persist/wbstack/src/Settings/LocalSettings.php index 49a8023ad..593a23f4b 100644 --- a/dist-persist/wbstack/src/Settings/LocalSettings.php +++ b/dist-persist/wbstack/src/Settings/LocalSettings.php @@ -44,6 +44,16 @@ $wgShowExceptionDetails = true; } +// profiling +// requires docker image to be built with dependencies +if( getenv('MW_ENABLE_PROFILING_HEADER') === '1' && isset ( $_SERVER['HTTP_X_WBSTACK_MW_PROFILING'] ) ) { + $wgProfiler['class'] = 'ProfilerXhprof'; + $wgProfiler['output'] = [ 'ProfilerOutputText', 'ProfilerOutputDump' ]; + $wgProfiler['outputDir'] = "/tmp/"; + $wgProfiler['visible'] = true; +} + + // Load Logging when not in phpunit or doing l10n rebuild if ( !$wwIsPhpUnit && !$wwIsLocalisationRebuild ) { $wgMWLoggerDefaultSpi = [ diff --git a/dist/wbstack/src/Settings/LocalSettings.php b/dist/wbstack/src/Settings/LocalSettings.php index 49a8023ad..593a23f4b 100644 --- a/dist/wbstack/src/Settings/LocalSettings.php +++ b/dist/wbstack/src/Settings/LocalSettings.php @@ -44,6 +44,16 @@ $wgShowExceptionDetails = true; } +// profiling +// requires docker image to be built with dependencies +if( getenv('MW_ENABLE_PROFILING_HEADER') === '1' && isset ( $_SERVER['HTTP_X_WBSTACK_MW_PROFILING'] ) ) { + $wgProfiler['class'] = 'ProfilerXhprof'; + $wgProfiler['output'] = [ 'ProfilerOutputText', 'ProfilerOutputDump' ]; + $wgProfiler['outputDir'] = "/tmp/"; + $wgProfiler['visible'] = true; +} + + // Load Logging when not in phpunit or doing l10n rebuild if ( !$wwIsPhpUnit && !$wwIsLocalisationRebuild ) { $wgMWLoggerDefaultSpi = [ diff --git a/install_profiling.sh b/install_profiling.sh new file mode 100755 index 000000000..c38e369ad --- /dev/null +++ b/install_profiling.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +cd /tmp && \ + git clone "https://github.com/tideways/php-xhprof-extension.git" && \ + cd php-xhprof-extension && \ + phpize && \ + ./configure && \ + make && \ + make install && \ + rm -rf /tmp/php-xhprof-extension && \ + echo "extension=tideways_xhprof.so" >> /usr/local/etc/php/conf.d/tweaks.ini \ No newline at end of file