BryanDavis has uploaded a new change for review.

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

Change subject: Guard use of ProfilerXhprof with ini check of 
hhvm.stats.enable_hot_profiler
......................................................................

Guard use of ProfilerXhprof with ini check of hhvm.stats.enable_hot_profiler

Don't try to use ProfilerXhprof if HHVM has been configured to disable
profiling completely.

Change-Id: Ie30ecb526b6dc1b2802fa5400ba65ed5613285cf
---
M wmf-config/StartProfiler.php
1 file changed, 22 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/mediawiki-config 
refs/changes/03/180903/1

diff --git a/wmf-config/StartProfiler.php b/wmf-config/StartProfiler.php
index ae4eb53..f9fa7c4 100644
--- a/wmf-config/StartProfiler.php
+++ b/wmf-config/StartProfiler.php
@@ -1,20 +1,29 @@
 <?php
-# WARNING: This file is publically viewable on the web. Do not put private 
data here.
+// WARNING: This file is publically viewable on the web. Do not put private
+// data here.
 
-# NOTE: this file is loaded early on in WebStart.php, so be careful with 
globals.
+// NOTE: this file is loaded early on in WebStart.php, so be careful with
+// globals.
 
-# Non-logged profiling for debugging
+$wmgUseXhprofProfiler = defined( 'HHVM_VERSION' )
+       && ini_get( 'hhvm.stats.enable_hot_profiler' );
+
 if ( isset( $_REQUEST['forceprofile'] ) ) {
-       if ( defined( 'HHVM_VERSION' ) ) {
+       // Non-logged profiling for debugging
+       if ( $wmgUseXhprofProfiler ) {
                $wgProfiler['class'] = 'ProfilerXhprof';
                $wgProfiler['flags'] = XHPROF_FLAGS_NO_BUILTINS;
        } else {
                $wgProfiler['class'] = 'ProfilerStandard';
        }
        $wgProfiler['output'] = 'text';
-# Profiling hack for test2 wiki (not sampled, but shouldn't distort too much)
-} elseif ( isset( $_SERVER['HTTP_HOST'] ) && $_SERVER['HTTP_HOST'] === 
'test2.wikipedia.org' ) {
-       if ( defined( 'HHVM_VERSION' ) ) {
+
+} elseif ( isset( $_SERVER['HTTP_HOST'] )
+       && $_SERVER['HTTP_HOST'] === 'test2.wikipedia.org' )
+{
+       // Profiling hack for test2 wiki (not sampled, but shouldn't distort too
+       // much)
+       if ( $wmgUseXhprofProfiler ) {
                $wgProfiler['class'] = 'ProfilerXhprof';
                $wgProfiler['flags'] = XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY | 
XHPROF_FLAGS_NO_BUILTINS;
        } else {
@@ -22,9 +31,10 @@
        }
        $wgProfiler['output'] = 'udp';
        $wgProfiler['profileID'] = 'test2';
-# Normal case: randomly (or not) selected for logged profiling sample
+
 } elseif ( false && $wmfDatacenter == 'eqiad' ) {
-       if ( defined( 'HHVM_VERSION' ) ) {
+       // Normal case: randomly (or not) selected for logged profiling sample
+       if ( $wmgUseXhprofProfiler ) {
                $wgProfiler['class'] = 'ProfilerXhprof';
                $wgProfiler['flags'] = XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY | 
XHPROF_FLAGS_NO_BUILTINS;
        } else {
@@ -43,8 +53,9 @@
        } else {
                $wgProfiler['profileID'] = $version;
        }
+
 } elseif ( $wmfRealm === 'labs' ) {
-       if ( defined( 'HHVM_VERSION' ) ) {
+       if ( $wmgUseXhprofProfiler ) {
                $wgProfiler['class'] = 'ProfilerXhprof';
                $wgProfiler['flags'] = XHPROF_FLAGS_CPU | XHPROF_FLAGS_MEMORY | 
XHPROF_FLAGS_NO_BUILTINS;
        } else {
@@ -55,7 +66,7 @@
        $wgProfiler['profileID'] = $coreGit->getHeadSHA1() ?: 'labs';
 }
 
-if ( defined( 'HHVM_VERSION' )
+if ( $wmgUseXhprofProfiler
        && isset( $_SERVER['HTTP_FORCE_LOCAL_XHPROF'] )
        && isset( $_SERVER['REMOTE_ADDR'] )
        && $_SERVER['REMOTE_ADDR'] == '127.0.0.1'

-- 
To view, visit https://gerrit.wikimedia.org/r/180903
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie30ecb526b6dc1b2802fa5400ba65ed5613285cf
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to