r56345 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56344‎ | r56345 | r56346 >
Date:22:10, 14 September 2009
Author:brion
Status:ok
Tags:
Comment:
Merge and clean up memory_limit hacks from wmf-deployment r53208.
Added a memoryLimit() method on Maintenance class which allows scripts to override the memory limit; normally we disable the limit but sometimes you actually want to set one to avoid eating up RAM on the machine if something goes awry.
Modified paths:
  • /trunk/phase3/maintenance/Maintenance.php (modified) (history)
  • /trunk/phase3/maintenance/gearman/gearmanWorker.php (modified) (history)
  • /trunk/phase3/maintenance/rebuildLocalisationCache.php (modified) (history)
  • /trunk/phase3/maintenance/runJobs.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/runJobs.php
@@ -36,6 +36,11 @@
3737 $this->addOption( 'procs', 'Number of processes to use', false, true );
3838 $wgUseNormalUser = true;
3939 }
 40+
 41+ public function memoryLimit() {
 42+ // Don't eat all memory on the machine if we get a bad job.
 43+ return "150M";
 44+ }
4045
4146 public function execute() {
4247 global $wgTitle;
Index: trunk/phase3/maintenance/Maintenance.php
@@ -333,7 +333,7 @@
334334 }
335335
336336 # Set the memory limit
337 - ini_set( 'memory_limit', -1 );
 337+ ini_set( 'memory_limit', $this->memoryLimit() );
338338
339339 # Set max execution time to 0 (no limit). PHP.net says that
340340 # "When running PHP from the command line the default setting is 0."
@@ -362,6 +362,15 @@
363363 $this->maybeHelp();
364364 $this->validateParamsAndArgs();
365365 }
 366+
 367+ /**
 368+ * Normally we disable the memory_limit when running admin scripts.
 369+ * Some scripts may wish to actually set a limit, however, to avoid
 370+ * blowing up unexpectedly.
 371+ */
 372+ public function memoryLimit() {
 373+ return -1;
 374+ }
366375
367376 /**
368377 * Clear all params and arguments.
Index: trunk/phase3/maintenance/rebuildLocalisationCache.php
@@ -37,12 +37,14 @@
3838 $this->addOption( 'force', 'Rebuild all files, even ones not out of date' );
3939 $this->addOption( 'threads', 'Fork more than one thread', false, true );
4040 }
 41+
 42+ public function memoryLimit() {
 43+ return '200M';
 44+ }
4145
4246 public function execute() {
4347 global $wgLocalisationCacheConf;
4448
45 - ini_set( 'memory_limit', '200M' );
46 -
4749 $force = $this->hasOption('force');
4850 $threads = $this->getOption( 'threads', 1 );
4951 if( $threads < 1 || $threads != intval( $threads ) ) {
Index: trunk/phase3/maintenance/gearman/gearmanWorker.php
@@ -4,6 +4,8 @@
55 require( dirname(__FILE__).'/../commandLine.inc' );
66 require( dirname(__FILE__).'/gearman.inc' );
77
 8+ini_set('memory_limit', '150M' );
 9+
810 if ( isset( $options['procs'] ) ) {
911 $procs = $options['procs'];
1012 if ( $procs < 1 || $procs > 1000 ) {

Follow-up revisions

RevisionCommit summaryAuthorDate
r56374Merge post-branch trunk updates replacing old live hacks:...brion17:25, 15 September 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r53208Apply live hacks, local merges, and removal of SVN externals -- all copied fr...brion23:50, 13 July 2009

Status & tagging log