fixed profiling; fixed wfMsg() use of memcached; put block log in initialdata.sql
authorTim Starling <tstarling@users.mediawiki.org>
Mon, 20 Oct 2003 13:39:40 +0000 (13:39 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Mon, 20 Oct 2003 13:39:40 +0000 (13:39 +0000)
INSTALL
includes/GlobalFunctions.php
includes/Profiling.php
includes/Setup.php
maintenance/initialdata.sql

diff --git a/INSTALL b/INSTALL
index 469f3b8..864f84d 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -128,7 +128,7 @@ And for math support:
 
 7. Unpack and configure PHP. Configure with something like:
 
-  ./configure --enable-apc --enable-shmop --with-zlib --with-zlib-dir=/usr/lib --with-mysql=/usr/local/mysql --with-iconv=/usr/local/lib --with-apache=/home/lee/src/apache_1.3.26
+  ./configure --enable-apc --enable-shmop --with-zlib --with-zlib-dir=/usr/lib --with-mysql=/usr/local/mysql --with-iconv=/usr/local/lib --with-apache=/home/lee/src/apache_1.3.26 --with-readline=/lib --enable-sockets
 
 Or for Apache 2.0 module:
   ./configure --enable-shmop --with-zlib --with-zlib-dir=/usr/lib --with-mysql=/usr/local/mysql --with-iconv --with-apxs2filter=/usr/local/apache/bin/apxs
index 9f28e23..ae0ae5e 100644 (file)
@@ -172,6 +172,7 @@ function wfMsgReal( $key, $args, $useDB ) {
                
        static $l1cache = array();
        $fname = "wfMsg";
+       wfProfileIn( $fname );
        $message = false;
        $l1hit = false;
        
@@ -209,7 +210,7 @@ function wfMsgReal( $key, $args, $useDB ) {
                                $obj = wfFetchObject( $res );
                                $message = $obj->cur_text;
                                wfFreeResult( $res );
-                               $wgMemc->set( $key, $message, time() + 1800 );
+                               $wgMemc->set( $mcKey, $message, 0 /*time() + 1800*/ );
                        }
                }
        }
@@ -226,9 +227,11 @@ function wfMsgReal( $key, $args, $useDB ) {
        if( count( $args ) ) {
                $message = str_replace( $wgReplacementKeys, $args, $message );
        }
+       
+       wfProfileOut( $fname );
 
        if ( "" == $message ) {
-               # Let's at least _try_ to be graceful about this.
+               # Failed, message not translated
                return "&lt;$key&gt;";
        }
        return $message;
index 091d01b..e82fd23 100755 (executable)
@@ -66,111 +66,61 @@ class Profiler
                }
        }
 
-
        function getOutput( $scriptStart, $scriptElapsed )
        {
-               set_time_limit( 0 );
-               $width = 80;
-               $format = "%-39s %6.2f / %6.2f = %6.2f %6.2f%%\n";
-               $prof = "";
                if( !count( $this->mStack ) ) {
                        return "No profiling output\n";
                }
+               
+               $format = "%-49s %6d %6.3f %6.3f %6.3f%%\n";
+               $titleFormat = "%-49s %9s %9s %9s %9s\n";
+               $prof = "\nProfiling data\n";
+               $prof .= sprintf( $titleFormat, "Name", "Calls", "Total", "Each", "%" );
                $this->mCollated = array();
-
-               $top = $this->doLevel( 0, true );
-               $this->merge( "WIKI.PHTML", $top, $scriptElapsed );
-               $this->mCollated = array_reverse( $this->mCollated, true );
-/*
-               # Calculate totals
-               foreach ( $this->mCollated as $f1 => $f1data ) {
-                       $total = 0;
-                       foreach ( $f1data as $f2 => $t ) {
-                               $total += $t;
-                       }
-                       $this->mCollated[$f1][0] = $total;
-               }
-*/
-               # Output
-               foreach ( $this->mCollated as $f1 => $f1data ) {
-                       $prof .= "\n" . str_repeat( "-", $width ) . "\n";
-                       $t = $this->mTotals[$f1] * 1000;
-                       $calls = $this->mCalls[$f1];
-                       if ( $calls == 0 ) {
-                               $calls = 1;
-                       }
-                       $each = $t / $calls;
-                       $percent = $this->mTotals[$f1] / $scriptElapsed * 100;
-                       $prof .= sprintf( $format, "| $f1", $t, $calls, $each, $percent );
-                       $prof .= str_repeat( "-", $width ) . "\n";
-                       foreach ( $f1data as $f2 => $t ) {
-                               $percent = $t / $this->mTotals[$f1] * 100;
-                               $t *= 1000;
-                               $calls = $this->mCalls[$f1];
-                               if ( $calls == 0 ) {
-                                       $calls = 1;
-                               }
-                               $each = $t / $calls;
-                               $percent = $this->mTotals[$f1] / $scriptElapsed * 100;
-                               $prof .= sprintf( $format, $f2, $t, $calls, $each, $percent );
-                       }
+               $this->mCalls = array();
+               $total = 0;
+               
+               # Estimate profiling overhead
+               $profileCount = count( $this->mStack );
+               for ($i=0; $i<$profileCount ; $i++) {
+                       wfProfileIn( "--profiling overhead--" );
+                       wfProfileOut( "--profiling overhead--" );
                }
-               $prof .= str_repeat( "-", $width ) . "\n";
-               return $prof;
-       }
                
-
-       function doLevel( $p, $fTop ) 
-       {
-               $level = false;
-               $getOut = false;
-               $hotArray = false;
-               $tempArray = array();
-               do {
-                       $fname = $this->mStack[$p][0];
-                       $thislevel = $this->mStack[$p][1];
-                       $start = (float)$this->mStack[$p][2] + (float)$this->mStack[$p][3];
-                       $end = (float)$this->mStack[$p][4] + (float)$this->mStack[$p][5];
+               # Collate
+               foreach ( $this->mStack as $entry ) {
+                       $fname = $entry[0];
+                       $thislevel = $entry[1];
+                       $start = explode( " ", $entry[2]);
+                       $start = (float)$start[0] + (float)$start[1];
+                       $end = explode( " ", $entry[3]);
+                       $end = (float)$end[0] + (float)$end[1];
                        $elapsed = $end - $start;
-                       if ( $hotArray !== false ) {
-                               # Just dropped down a level
-                               # Therefore this entry is the parent of $hotArray
-                               $this->merge( $fname, $hotArray, $elapsed );
-                               $hotArray = false;
-                       }
-
-                       if ( $level === false ) {
-                               $level = $thislevel;
-                       }
-
-                       if ( $thislevel == $level ) {
-                               $tempArray[$fname] += $elapsed;
-                               #$this->mTotals[$fname] += elapsed;
-                               $this->mCalls[$fname] ++;
-                       } elseif ($thislevel > $level ) {
-                               $hotArray = $this->doLevel( $p, false );
-                       } else {
-                               $getOut = true;
+                       $this->mCollated[$fname] += $elapsed;
+                       $this->mCalls[$fname] ++;
+                       
+                       if ( $fname != "--profiling overhead--" ) {
+                               $total += $elapsed;
                        }
-
-                       # Special case: top of hierarchy
-                       # File starts with lvl 1 entry, then drops back to lvl 0
-                       if ( $fTop && $getOut ) {
-                               $hotArray = $tempArray;
-                               $getOut = false;
+               }
+               
+               $overhead = $this->mCollated["--profiling overhead--"] / $this->mCalls["--profiling overhead--"];
+               
+               # Output
+               foreach ( $this->mCollated as $fname => $elapsed ) {
+                       $calls = $this->mCalls[$fname];
+                       # Adjust for overhead
+                       if ( $fname != "--profiling overhead--" ) {
+                               $elapsed -= $overhead * $calls;
                        }
-
-                       $p++;
-               } while ( !$getOut && $p < count( $this->mStack ) );
-               return $tempArray;
-       }
-
-       function merge( $f1, $a, $parentTime ) 
-       {
-               foreach ( $a as $f2 => $elapsed ) {
-                       $this->mCollated[$f1][$f2] += $elapsed;
+                       
+                       $percent = $total ? 100. * $elapsed / $total : 0;
+                       $prof .= sprintf( $format, $fname, $calls, (float)($elapsed * 1000), 
+                               (float)($elapsed * 1000) / $calls, $percent );
                }
-               $this->mTotals[$f1] += $parentTime;
+               $prof .= "\nTotal: $total\n\n";
+
+               return $prof;
        }
 }
 
index 80f0c0b..e82809f 100644 (file)
@@ -22,7 +22,7 @@ include_once( "$IP/Block.php" );
 
 global $wgUser, $wgLang, $wgOut, $wgTitle;
 global $wgArticle, $wgDeferredUpdateList, $wgLinkCache;
-global $wgMemc, $wgMagicWords, $wgMwRedir;
+global $wgMemc, $wgMagicWords, $wgMwRedir, $wgDebugLogFile;
 
 class MemCachedClientforWiki extends MemCachedClient {
        function _debug( $text ) {
@@ -34,6 +34,11 @@ $wgMemc = new MemCachedClientforWiki();
 if( $wgUseMemCached ) {
        $wgMemc->set_servers( $wgMemCachedServers );
        $wgMemc->set_debug( $wgMemCachedDebug );
+
+       # Test it to see if it's working
+       if ( $wgDebugLogFile && !$wgMemc->set( "test", "", 0 ) ) {
+               wfDebug( "Memcached error: " . $wgMemc->error_string() . "\n" );
+       }
 }
 
 include_once( "$IP/Language.php" );
index 7e6ec37..141c71a 100644 (file)
@@ -9,7 +9,10 @@ INSERT INTO user (user_name,user_rights,user_password)
 INSERT INTO cur (cur_namespace,cur_title,cur_text,cur_restrictions)
   VALUES (4,'Upload_log','Below is a list of the most recent file uploads.\nAll times shown are server time (UTC).\n<ul>\n</ul>\n','sysop'),
   (4,'Deletion_log','Below is a list of the most recent deletions.\nAll times shown are server time (UTC).\n<ul>\n</ul>\n','sysop'),
-  (0,'Main_Page','Wiki software successfully installed!','');
+  (0,'Main_Page','Wiki software successfully installed!',''),
+  (4,'Block log', 'This is a log of user blocking and unblocking actions. Automatically 
+blocked IP addresses are not be listed. See the [[Special:Ipblocklist|IP block list]] for
+the list of currently operational bans and blocks.', 'sysop');
 
 INSERT INTO site_stats VALUES (1,0,0,0);