* Use revision rate for ETA in dump generation; it tends to be more stable
authorBrion Vibber <brion@users.mediawiki.org>
Thu, 26 Jan 2006 08:06:05 +0000 (08:06 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Thu, 26 Jan 2006 08:06:05 +0000 (08:06 +0000)
  than the per-page count for full-history dumps.

RELEASE-NOTES
maintenance/backup.inc
maintenance/dumpTextPass.php

index ea87dc8..762f8d0 100644 (file)
@@ -569,6 +569,9 @@ fully support the editing toolbar, but was found to be too confusing.
 * Do not tidy interface messages (unless full tidy is set)
 * Do not trust equality propagation and give more hints to MySQL
   optimizer for revision fetches (avoids index scans)
+* Use revision rate for ETA in dump generation; it tends to be more stable
+  than the per-page count for full-history dumps.
+
 
 === Caveats ===
 
index e6ade44..bef9b3f 100644 (file)
@@ -154,11 +154,7 @@ class BackupDumper {
                # relatively harmless.
                ini_set( 'display_errors', false );
 
-               $this->startTime = wfTime();
-
-               $dbr =& wfGetDB( DB_SLAVE );
-               $this->maxCount = $dbr->selectField( 'page', 'MAX(page_id)', '', 'BackupDumper::dump' );
-               $this->startTime = wfTime();
+               $this->initProgress( $history );
 
                $db =& $this->backupDb();
                $exporter = new WikiExporter( $db, $history, MW_EXPORT_STREAM, $text );
@@ -184,6 +180,21 @@ class BackupDumper {
 
                $this->report( true );
        }
+       
+       /**
+        * Initialise starting time and maximum revision count.
+        * We'll make ETA calculations based an progress, assuming relatively
+        * constant per-revision rate.
+        * @param int $history MW_EXPORT_CURRENT or MW_EXPORT_FULL
+        */
+       function initProgress( $history = MW_EXPORT_FULL ) {
+               $table = ($history == MW_EXPORT_CURRENT) ? 'page' : 'revision';
+               $field = ($history == MW_EXPORT_CURRENT) ? 'page_id' : 'rev_id';
+               
+               $dbr =& wfGetDB( DB_SLAVE );
+               $this->maxCount = $dbr->selectField( $table, "MAX($field)", '', 'BackupDumper::dump' );
+               $this->startTime = wfTime();
+       }
 
        function &backupDb() {
                global $wgDBadminuser, $wgDBadminpassword;
@@ -205,15 +216,15 @@ class BackupDumper {
 
        function reportPage() {
                $this->pageCount++;
-               $this->report();
        }
 
        function revCount() {
                $this->revCount++;
+               $this->report();
        }
 
        function report( $final = false ) {
-               if( $final xor ( $this->pageCount % $this->reportingInterval == 0 ) ) {
+               if( $final xor ( $this->revCount % $this->reportingInterval == 0 ) ) {
                        $this->showReport();
                }
        }
@@ -225,7 +236,7 @@ class BackupDumper {
                        if( $delta ) {
                                $rate = $this->pageCount / $delta;
                                $revrate = $this->revCount / $delta;
-                               $portion = $this->pageCount / $this->maxCount;
+                               $portion = $this->revCount / $this->maxCount;
                                $eta = $this->startTime + $delta / $portion;
                                $etats = wfTimestamp( TS_DB, intval( $eta ) );
                        } else {
@@ -234,7 +245,8 @@ class BackupDumper {
                                $etats = '-';
                        }
                        global $wgDBname;
-                       $this->progress( "$now: $wgDBname $this->pageCount, ETA $etats ($rate pages/sec $revrate revs/sec)" );
+                       $this->progress( sprintf( "%s: %s %d pages (%0.3f/sec), %d revs (%0.3f/sec), ETA %s [max %d]",
+                               $now, $wgDBname, $this->pageCount, $rate, $this->revCount, $revrate, $etats, $this->maxCount ) );
                }
        }
 
index ca03e70..5991ec4 100644 (file)
@@ -33,6 +33,7 @@ require_once( 'maintenance/backup.inc' );
 class TextPassDumper extends BackupDumper {
        var $prefetch = null;
        var $input = "php://stdin";
+       var $history = MW_EXPORT_FULL;
 
        function dump() {
                # This shouldn't happen if on console... ;)
@@ -42,11 +43,9 @@ class TextPassDumper extends BackupDumper {
                # relatively harmless.
 //             ini_set( 'display_errors', false );
 
-               $this->startTime = wfTime();
+               $this->initProgress( $this->history );
 
                $this->db =& $this->backupDb();
-               $this->maxCount = $this->db->selectField( 'page', 'MAX(page_id)', '', 'BackupDumper::dump' );
-               $this->startTime = wfTime();
 
                $this->egress = new ExportProgressFilter( $this->sink, $this );
 
@@ -71,6 +70,12 @@ class TextPassDumper extends BackupDumper {
                case 'stub':
                        $this->input = $url;
                        break;
+               case 'current':
+                       $this->history = MW_EXPORT_CURRENT;
+                       break;
+               case 'full':
+                       $this->history = MW_EXPORT_FULL;
+                       break;
                }
        }
        
@@ -229,6 +234,7 @@ Options:
   --report=n  Report position and speed after every n pages processed.
               (Default: 100)
   --server=h  Force reading from MySQL server h
+  --current   Base ETA on number of pages in database instead of all revisions
 END
 );
 }