Ori.livneh has uploaded a new change for review.

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

Change subject: xenon profiling: fix undefined notice; decouple from mw
......................................................................

xenon profiling: fix undefined notice; decouple from mw

Change-Id: I0f75dcbd705572682eb2e740c826425410f95c18
---
M wmf-config/StartProfiler.php
1 file changed, 19 insertions(+), 14 deletions(-)


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

diff --git a/wmf-config/StartProfiler.php b/wmf-config/StartProfiler.php
index e59c095..b019be4 100644
--- a/wmf-config/StartProfiler.php
+++ b/wmf-config/StartProfiler.php
@@ -95,30 +95,35 @@
                if ( empty( $data ) ) {
                        return;
                }
+
                // Collate stack samples and fold into single lines.
                // This is the format expected by FlameGraph.
+               $stacks = array();
+
                foreach ( $data as $sample ) {
                        $stack = array();
+
                        foreach( $sample['phpStack'] as $frame ) {
-                               if ( !in_array( $frame['function'], $omit ) ) {
-                                       $stack[] = $frame['function'];
+                               $func = $frame['function'];
+                               if ( $func !== end( $stack ) && !in_array( 
$func, $omit ) ) {
+                                       $stack[] = $func;
                                }
                        }
-                       if ( !empty( $stack ) ) {
-                               $stack = implode( ';', array_reverse( $stack ) 
);
-                               $stacks[$stack] += 1;
+
+                       if ( count( $stack ) ) {
+                               $strStack = implode( ';', array_reverse( $stack 
) );
+                               if ( !isset( $stacks[$strStack] ) ) {
+                                       $stacks[$strStack] = 0;
+                               }
+                               $stacks[$strStack] += 1;
                        }
                }
 
-               $options = array( 'serializer' => 'none' );
-               $pool = RedisConnectionPool::singleton( $options );
-               $conn = $pool->getConnection( 'fluorine.eqiad.wmnet:6379' );
-               if ( !$conn ) {
-                       return;
-               }
-
-               foreach ( $stacks as $stack => $count ) {
-                       $conn->publish( 'xenon', "$stack $count" );
+               $redis = new Redis();
+               if ( $redis->connect( 'fluorine.eqiad.wmnet', 6379, 0.1 ) ) {
+                       foreach ( $stacks as $stack => $count ) {
+                               $redis->publish( 'xenon', "$stack $count" );
+                       }
                }
        } );
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0f75dcbd705572682eb2e740c826425410f95c18
Gerrit-PatchSet: 1
Gerrit-Project: operations/mediawiki-config
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

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

Reply via email to