From 5009897bee0407018e5fa7bb56b6d0c8ff2610f6 Mon Sep 17 00:00:00 2001 From: Domas Mituzas Date: Sun, 28 May 2006 17:05:22 +0000 Subject: [PATCH] Added proper pf_server definition to table, enabled to turn on/off per-app-server profiling --- includes/DefaultSettings.php | 2 ++ includes/Profiling.php | 13 ++++++++++--- maintenance/archives/patch-profiling.sql | 3 ++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 4a8cda7c45..b9b1e10ecc 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -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'; diff --git a/includes/Profiling.php b/includes/Profiling.php index 52d8de86ec..42d0a6eb54 100644 --- a/includes/Profiling.php +++ b/includes/Profiling.php @@ -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: diff --git a/maintenance/archives/patch-profiling.sql b/maintenance/archives/patch-profiling.sql index 30d5322776..49b488e921 100644 --- a/maintenance/archives/patch-profiling.sql +++ b/maintenance/archives/patch-profiling.sql @@ -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; -- 2.20.1