r95634 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95633‎ | r95634 | r95635 >
Date:19:06, 28 August 2011
Author:ariel
Status:ok
Tags:
Comment:
move some member vars to parent class since they are needed there now, set lastTime and other vars so checkpoints without prefetch work, update progress reporting in parent class to give rates during interval and from start of run
Modified paths:
  • /trunk/phase3/maintenance/backup.inc (modified) (history)
  • /trunk/phase3/maintenance/dumpTextPass.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/backup.inc
@@ -51,6 +51,10 @@
5252 var $stubText = false; // include rev_text_id instead of text; for 2-pass dump
5353 var $dumpUploads = false;
5454 var $dumpUploadFileContents = false;
 55+ var $lastTime = 0;
 56+ var $pageCountLast = 0;
 57+ var $revCountLast = 0;
 58+ var $ID = 0;
5559
5660 function BackupDumper( $args ) {
5761 $this->stderr = fopen( "php://stderr", "wt" );
@@ -233,6 +237,8 @@
234238 $dbr = wfGetDB( DB_SLAVE );
235239 $this->maxCount = $dbr->selectField( $table, "MAX($field)", '', __METHOD__ );
236240 $this->startTime = wfTime();
 241+ $this->lastTime = $this->startTime;
 242+ $this->ID = getmypid();
237243 }
238244
239245 /**
@@ -281,21 +287,35 @@
282288
283289 function showReport() {
284290 if ( $this->reporting ) {
285 - $delta = wfTime() - $this->startTime;
286291 $now = wfTimestamp( TS_DB );
287 - if ( $delta ) {
288 - $rate = $this->pageCount / $delta;
289 - $revrate = $this->revCount / $delta;
 292+ $nowts = wfTime();
 293+ $deltaAll = wfTime() - $this->startTime;
 294+ $deltaPart = wfTime() - $this->lastTime;
 295+ $this->pageCountPart = $this->pageCount - $this->pageCountLast;
 296+ $this->revCountPart = $this->revCount - $this->revCountLast;
 297+
 298+ if ( $deltaAll ) {
290299 $portion = $this->revCount / $this->maxCount;
291 - $eta = $this->startTime + $delta / $portion;
 300+ $eta = $this->startTime + $deltaAll / $portion;
292301 $etats = wfTimestamp( TS_DB, intval( $eta ) );
 302+ $pageRate = $this->pageCount / $deltaAll;
 303+ $revRate = $this->revCount / $deltaAll;
293304 } else {
294 - $rate = '-';
295 - $revrate = '-';
 305+ $pageRate = '-';
 306+ $revRate = '-';
296307 $etats = '-';
297308 }
298 - $this->progress( sprintf( "%s: %s %d pages (%0.3f/sec), %d revs (%0.3f/sec), ETA %s [max %d]",
299 - $now, wfWikiID(), $this->pageCount, $rate, $this->revCount, $revrate, $etats, $this->maxCount ) );
 309+ if ( $deltaPart ) {
 310+ $pageRatePart = $this->pageCountPart / $deltaPart;
 311+ $revRatePart = $this->revCountPart / $deltaPart;
 312+ } else {
 313+ $pageRatePart = '-';
 314+ $revRatePart = '-';
 315+ }
 316+ $this->progress( sprintf( "%s: %s (ID %d) %d pages (%0.1f|%0.1f/sec all|curr), %d revs (%0.1f|%0.1f/sec all|curr), ETA %s [max %d]",
 317+ $now, wfWikiID(), $this->ID, $this->pageCount, $pageRate, $pageRatePart, $this->revCount, $revRate, $revRatePart, $etats, $this->maxCount ) );
 318+ $this->lastTime = $nowts;
 319+ $this->revCountLast = $this->revCount;
300320 }
301321 }
302322
Index: trunk/phase3/maintenance/dumpTextPass.php
@@ -38,9 +38,6 @@
3939 var $history = WikiExporter::FULL;
4040 var $fetchCount = 0;
4141 var $prefetchCount = 0;
42 - var $lastTime = 0;
43 - var $pageCountLast = 0;
44 - var $revCountLast = 0;
4542 var $prefetchCountLast = 0;
4643 var $fetchCountLast = 0;
4744
@@ -57,8 +54,6 @@
5855 var $spawnRead = false;
5956 var $spawnErr = false;
6057
61 - var $ID = 0;
62 -
6358 var $xmlwriterobj = false;
6459
6560 # when we spend more than maxTimeAllowed seconds on this run, we continue
@@ -73,8 +68,6 @@
7469
7570 function initProgress( $history ) {
7671 parent::initProgress();
77 - $this->ID = getmypid();
78 - $this->lastTime = $this->startTime;
7972 $this->timeOfCheckpoint = $this->startTime;
8073 }
8174
@@ -234,10 +227,6 @@
235228 }
236229
237230 function checkIfTimeExceeded() {
238 - $m1 = $this->maxTimeAllowed;
239 - $m2 = $this->lastTime;
240 - $m3 = $this->timeOfCheckpoint;
241 - $m4 = $this->lastTime - $this->timeOfCheckpoint;
242231 if ( $this->maxTimeAllowed && ( $this->lastTime - $this->timeOfCheckpoint > $this->maxTimeAllowed ) ) {
243232 return True;
244233 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r96556MFT r95260, r95272, r95288, r95290, r95443, r95601, r95604, r95634, r95720, r...reedy12:28, 8 September 2011

Status & tagging log