Added proper pf_server definition to table, enabled to turn on/off per-app-server...
authorDomas Mituzas <midom@users.mediawiki.org>
Sun, 28 May 2006 17:05:22 +0000 (17:05 +0000)
committerDomas Mituzas <midom@users.mediawiki.org>
Sun, 28 May 2006 17:05:22 +0000 (17:05 +0000)
includes/DefaultSettings.php
includes/Profiling.php
maintenance/archives/patch-profiling.sql

index 4a8cda7..b9b1e10 100644 (file)
@@ -1125,6 +1125,8 @@ $wgProfileSampleRate = 1;
 $wgProfileCallTree = false;
 /** If not empty, specifies profiler type to load */
 $wgProfilerType = '';
+/** Should application server host be put into profiling table */
+$wgProfilePerHost = false;
 
 /** Settings for UDP profiler */
 $wgUDPProfilerHost = '127.0.0.1';
index 52d8de8..42d0a6e 100644 (file)
@@ -319,7 +319,7 @@ class Profiler {
         */
        function logToDB($name, $timeSum, $eventCount) {
                # Warning: $wguname is a live patch, it should be moved to Setup.php
-               global $wguname;
+               global $wguname, $wgProfilePerHost;
 
                $fname = 'Profiler::logToDB';
                $dbw = & wfGetDB(DB_MASTER);
@@ -330,14 +330,21 @@ class Profiler {
 
                $name = substr($name, 0, 255);
                $encname = $dbw->strencode($name);
+               
+               if ($wgProfilePerHost) {
+                       $pfhost = $wguname['nodename'];
+               } else {
+                       $pfhost = '';
+               }
+
                $sql = "UPDATE $profiling "."SET pf_count=pf_count+{$eventCount}, "."pf_time=pf_time + {$timeSum} ".
-                       "WHERE pf_name='{$encname}' AND pf_server='{$wguname['nodename']}'";
+                       "WHERE pf_name='{$encname}' AND pf_server='{$pfhost}'";
                $dbw->query($sql);
 
                $rc = $dbw->affectedRows();
                if ($rc == 0) {
                        $dbw->insert('profiling', array ('pf_name' => $name, 'pf_count' => $eventCount,
-                               'pf_time' => $timeSum, 'pf_server' => $wguname['nodename'] ), $fname, array ('IGNORE'));
+                               'pf_time' => $timeSum, 'pf_server' => $pfhost ), $fname, array ('IGNORE'));
                }
                // When we upgrade to mysql 4.1, the insert+update
                // can be merged into just a insert with this construct added:
index 30d5322..49b488e 100644 (file)
@@ -5,5 +5,6 @@ CREATE TABLE /*$wgDBprefix*/profiling (
        pf_count integer not null default 0,
        pf_time float not null default 0,
        pf_name varchar(255) not null default '',
-       UNIQUE KEY pf_name (pf_name)
+       pf_server varchar(30) not null default '',
+       UNIQUE KEY pf_name_server (pf_name, pf_server)
 ) TYPE=HEAP;