diff --git a/README.md b/README.md index 6757889..4495151 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ Magento - Product with options - Product reviews -Mediawiki +MediaWiki --------- The main page is the Barack Obama page from Wikipedia; this is based on the @@ -185,21 +185,6 @@ Wikimedia Foundation using it as a benchmark, and finding it fairly representative of Wikipedia. A few other pages (HHVM, talk, edit) are also loaded to provide a slightly more rounded workload. -- MySQL-based view counters have been disabled: they are incredibly inefficient, - unlikely to be used in any high-concurrency deployment (for example, Wikipedia - disables them), and will be removed in a future release of Mediawiki. -- Localisation caching has been switched from MySQL to file-based. MySQL-based - L10N caching 'just works', but it is also inefficient (1 query per localizable - string per page view), and unlikely to be used in high-concurrency deployments. - This setting is also used by Wikipedia. -- If `--apply-patches` is specified, the existing file cache is replaced with a - more efficient version that simply uses static PHP arrays. This has been - submitted to the upstream project at https://phabricator.wikimedia.org/T99740 - -Each of these modifications improves performance under all tested runtimes: PHP5, -PHP7, and HHVM. The concurrency issues with the MySQL-based view counters and -L10N caching are because of contention within MySQL server. - Profiling ========= diff --git a/targets/mediawiki/LocalSettings.php b/targets/mediawiki/LocalSettings.php new file mode 100644 index 0000000..dcb7bd8 --- /dev/null +++ b/targets/mediawiki/LocalSettings.php @@ -0,0 +1,158 @@ +getSourceRoot()); } else { Utils::ExtractTar( - __DIR__.'/mediawiki-1.24.0.tar.gz', + __DIR__.'/'.self::MEDIAWIKI_VERSION.'.tar.gz', $this->options->tempDir, ); } @@ -37,18 +40,10 @@ public function install(): void { $cache_dir = $this->getSourceRoot().'/mw-cache'; mkdir($cache_dir); + copy(__DIR__.'/LocalSettings.php', $this->getSourceRoot().'/LocalSettings.php') file_put_contents( $this->getSourceRoot().'/LocalSettings.php', - '$wgCacheDirectory="'. - $cache_dir. - '";'. - // Default behavior is to do a MySQL query *for each translatable string - // on every page view*. This is just insane. - '$wgLocalisationCacheConf["store"] = "file";'. - // Default behavior is to maintain view counts in MySQL. Any real - // large-scale deployment should be using a more scalable solution such - // as log files or Google Analytics - '$wgDisableCounters = true;', + '$wgCacheDirectory="'.$cache_dir.'";', FILE_APPEND, ); } @@ -65,6 +60,6 @@ public function postInstall(): void { } public function getSourceRoot(): string { - return $this->options->tempDir.'/mediawiki'; + return $this->options->tempDir.'/'.self::MEDIAWIKI_VERSION; } } diff --git a/targets/mediawiki/mediawiki-1.24.0.tar.gz b/targets/mediawiki/mediawiki-1.26.1.tar.gz similarity index 63% rename from targets/mediawiki/mediawiki-1.24.0.tar.gz rename to targets/mediawiki/mediawiki-1.26.1.tar.gz index 07ab6b2..26db30e 100644 Binary files a/targets/mediawiki/mediawiki-1.24.0.tar.gz and b/targets/mediawiki/mediawiki-1.26.1.tar.gz differ diff --git a/targets/mediawiki/mw_bench.sql.gz b/targets/mediawiki/mw_bench.sql.gz index 0aee217..ca3c1fa 100644 Binary files a/targets/mediawiki/mw_bench.sql.gz and b/targets/mediawiki/mw_bench.sql.gz differ diff --git a/targets/mediawiki/patches/0001-LCStoreStaticArray.patch b/targets/mediawiki/patches/0001-LCStoreStaticArray.patch deleted file mode 100644 index 975175f..0000000 --- a/targets/mediawiki/patches/0001-LCStoreStaticArray.patch +++ /dev/null @@ -1,99 +0,0 @@ ---- a/includes/cache/LocalisationCache.php 2014-11-26 18:39:08.000000000 -0800 -+++ b/includes/cache/LocalisationCache.php 2015-05-19 17:06:55.230062823 -0700 -@@ -195,7 +195,8 @@ - switch ( $conf['store'] ) { - case 'files': - case 'file': -- $storeClass = 'LCStoreCDB'; -+ $storeClass = 'LCStoreStaticArray'; -+ //$storeClass = 'LCStoreCDB'; - break; - case 'db': - $storeClass = 'LCStoreDB'; -@@ -1131,6 +1132,86 @@ - function set( $key, $value ); - } - -+class LCStoreStaticArray implements LCStore { -+ private $currentLang = null; -+ private $data = array(); -+ private $fname = null; -+ private $dir; -+ -+ public function __construct($conf) { -+ global $wgCacheDirectory; -+ $this->dir = $wgCacheDirectory; -+ } -+ -+ public function startWrite($code) { -+ $this->currentLang = $code; -+ $this->fname = $this->dir.'/'.$code.'.l10n.php'; -+ $this->data[$code] = array(); -+ if (file_exists($this->fname)) { -+ $this->data[$code] = require($this->fname); -+ } -+ } -+ -+ public function set($key, $value) { -+ $this->data[$this->currentLang][$key] = self::encode($value); -+ } -+ -+ private static function encode($value) { -+ if (is_scalar($value) || $value === null) { -+ // [V]alue -+ return ['v', $value]; -+ } -+ if (is_object($value)) { -+ // [S]erialized -+ return ['s', serialize($value)]; -+ } -+ if (is_array($value)) { -+ // [A]rray -+ return ['a', array_map(function($v) { return self::encode($v); }, $value)]; -+ } -+ -+ die("Can't encode '".var_export($value, true)."'"); -+ } -+ -+ private static function decode($encoded) { -+ $type = $encoded[0]; -+ $data = $encoded[1]; -+ -+ if ($type === 'v') { -+ return $data; -+ } -+ if ($type === 's') { -+ return unserialize($data); -+ } -+ if ($type === 'a') { -+ return array_map(function($v) { return self::decode($v); }, $data); -+ } -+ -+ die("Can't decode: '".var_export($encoded, true)."'"); -+ } -+ -+ public function finishWrite() { -+ file_put_contents($this->fname, 'data[$this->currentLang], true).';'); -+ $this->currentLang = null; -+ $this->fname = null; -+ } -+ -+ public function get($code, $key) { -+ if (!array_key_exists($code, $this->data)) { -+ $fname = $this->dir.'/'.$code.'.l10n.php'; -+ if (!file_exists($fname)) { -+ return null; -+ } -+ $this->data[$code] = require($fname); -+ } -+ $data = $this->data[$code]; -+ if (array_key_exists($key, $data)) { -+ return self::decode($data[$key]); -+ } -+ return null; -+ } -+} -+ - /** - * LCStore implementation which uses the standard DB functions to store data. - * This will work on any MediaWiki installation.