2006-01-28 08:22:24 +00:00
|
|
|
<?php
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
/**
|
2012-07-25 19:31:06 +00:00
|
|
|
* Makes several 'set', 'incr' and 'get' requests on every memcached
|
|
|
|
|
* server and shows a report.
|
2008-07-19 12:15:07 +00:00
|
|
|
*
|
2009-08-02 19:35:17 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
|
*
|
2012-07-25 19:31:06 +00:00
|
|
|
* @file
|
WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>
Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage
One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2006-01-28 08:22:24 +00:00
|
|
|
|
2013-05-17 00:16:59 +00:00
|
|
|
require_once __DIR__ . '/Maintenance.php';
|
2009-06-24 02:49:24 +00:00
|
|
|
|
2012-07-25 19:31:06 +00:00
|
|
|
/**
|
|
|
|
|
* Maintenance script that makes several 'set', 'incr' and 'get' requests
|
|
|
|
|
* on every memcached server and shows a report.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup Maintenance
|
|
|
|
|
*/
|
2013-11-23 21:53:29 +00:00
|
|
|
class McTest extends Maintenance {
|
2009-08-02 19:35:17 +00:00
|
|
|
public function __construct() {
|
|
|
|
|
parent::__construct();
|
2016-01-30 02:48:47 +00:00
|
|
|
$this->addDescription( "Makes several 'set', 'incr' and 'get' requests on every"
|
|
|
|
|
. " memcached server and shows a report" );
|
2009-08-02 19:35:17 +00:00
|
|
|
$this->addOption( 'i', 'Number of iterations', false, true );
|
2013-03-15 06:09:24 +00:00
|
|
|
$this->addOption( 'cache', 'Use servers from this $wgObjectCaches store', false, true );
|
2011-09-06 23:21:39 +00:00
|
|
|
$this->addArg( 'server[:port]', 'Memcached server to test, with optional port', false );
|
2009-08-02 19:35:17 +00:00
|
|
|
}
|
2006-01-28 08:22:24 +00:00
|
|
|
|
2009-08-02 19:35:17 +00:00
|
|
|
public function execute() {
|
2013-01-16 23:51:43 +00:00
|
|
|
global $wgMainCacheType, $wgMemCachedTimeout, $wgObjectCaches;
|
2009-06-24 02:49:24 +00:00
|
|
|
|
2013-03-15 06:09:24 +00:00
|
|
|
$cache = $this->getOption( 'cache' );
|
2009-08-02 19:35:17 +00:00
|
|
|
$iterations = $this->getOption( 'i', 100 );
|
2013-03-15 06:09:24 +00:00
|
|
|
if ( $cache ) {
|
|
|
|
|
if ( !isset( $wgObjectCaches[$cache] ) ) {
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( "MediaWiki isn't configured with a cache named '$cache'" );
|
2013-03-15 06:09:24 +00:00
|
|
|
}
|
|
|
|
|
$servers = $wgObjectCaches[$cache]['servers'];
|
|
|
|
|
} elseif ( $this->hasArg() ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$servers = [ $this->getArg() ];
|
2013-01-16 23:51:43 +00:00
|
|
|
} elseif ( $wgMainCacheType === CACHE_MEMCACHED ) {
|
|
|
|
|
global $wgMemCachedServers;
|
2013-04-18 18:48:44 +00:00
|
|
|
$servers = $wgMemCachedServers;
|
2013-03-15 06:09:24 +00:00
|
|
|
} elseif ( isset( $wgObjectCaches[$wgMainCacheType]['servers'] ) ) {
|
2013-01-16 23:51:43 +00:00
|
|
|
$servers = $wgObjectCaches[$wgMainCacheType]['servers'];
|
|
|
|
|
} else {
|
2017-11-20 00:36:54 +00:00
|
|
|
$this->fatalError( "MediaWiki isn't configured for Memcached usage" );
|
2012-01-22 00:58:47 +00:00
|
|
|
}
|
2006-01-28 08:22:24 +00:00
|
|
|
|
2013-07-31 12:25:30 +00:00
|
|
|
# find out the longest server string to nicely align output later on
|
|
|
|
|
$maxSrvLen = $servers ? max( array_map( 'strlen', $servers ) ) : 0;
|
|
|
|
|
|
2013-01-16 23:51:43 +00:00
|
|
|
foreach ( $servers as $server ) {
|
2013-07-31 12:25:30 +00:00
|
|
|
$this->output(
|
|
|
|
|
str_pad( $server, $maxSrvLen ),
|
2014-04-23 18:09:13 +00:00
|
|
|
$server # output channel
|
2013-07-31 12:25:30 +00:00
|
|
|
);
|
|
|
|
|
|
2016-04-03 08:52:50 +00:00
|
|
|
$mcc = new MemcachedClient( [
|
2012-04-27 04:51:52 +00:00
|
|
|
'persistant' => true,
|
|
|
|
|
'timeout' => $wgMemCachedTimeout
|
2016-02-17 09:09:32 +00:00
|
|
|
] );
|
|
|
|
|
$mcc->set_servers( [ $server ] );
|
2009-08-02 19:35:17 +00:00
|
|
|
$set = 0;
|
|
|
|
|
$incr = 0;
|
|
|
|
|
$get = 0;
|
2014-07-17 03:21:00 +00:00
|
|
|
$time_start = microtime( true );
|
2010-05-22 16:50:39 +00:00
|
|
|
for ( $i = 1; $i <= $iterations; $i++ ) {
|
2013-09-17 22:23:44 +00:00
|
|
|
if ( $mcc->set( "test$i", $i ) ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$set++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-22 16:50:39 +00:00
|
|
|
for ( $i = 1; $i <= $iterations; $i++ ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
if ( !is_null( $mcc->incr( "test$i", $i ) ) ) {
|
|
|
|
|
$incr++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-05-22 16:50:39 +00:00
|
|
|
for ( $i = 1; $i <= $iterations; $i++ ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$value = $mcc->get( "test$i" );
|
2010-05-22 16:50:39 +00:00
|
|
|
if ( $value == $i * 2 ) {
|
2009-08-02 19:35:17 +00:00
|
|
|
$get++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-07-17 03:21:00 +00:00
|
|
|
$exectime = microtime( true ) - $time_start;
|
2010-12-04 03:20:14 +00:00
|
|
|
|
2013-07-31 12:25:30 +00:00
|
|
|
$this->output( " set: $set incr: $incr get: $get time: $exectime", $server );
|
2009-06-24 02:49:24 +00:00
|
|
|
}
|
2006-01-28 08:22:24 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-13 00:02:09 +00:00
|
|
|
$maintClass = McTest::class;
|
2013-05-07 23:00:15 +00:00
|
|
|
require_once RUN_MAINTENANCE_IF_MAIN;
|