From 9ca1867de166eef2467a257b50297f41ae6784a9 Mon Sep 17 00:00:00 2001 From: Carlos Torres Date: Tue, 14 Jan 2020 13:54:55 -0800 Subject: [PATCH] Add MLP target, a memory intensive variation of MediaWiki --- base/PerfOptions.php | 3 +- conf/nginx/nginx.conf.in | 4 +- targets/mediawiki/MediaWikiMLPTarget.php | 89 +++++++++++++++++++++++ targets/mediawiki/MediaWikiMLPTarget.urls | 24 ++++++ targets/mediawiki/Memcached.php | 8 ++ targets/mediawiki/mlp.php | 52 +++++++++++++ 6 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 targets/mediawiki/MediaWikiMLPTarget.php create mode 100644 targets/mediawiki/MediaWikiMLPTarget.urls create mode 100644 targets/mediawiki/mlp.php diff --git a/base/PerfOptions.php b/base/PerfOptions.php index 057002d..1537207 100644 --- a/base/PerfOptions.php +++ b/base/PerfOptions.php @@ -357,7 +357,7 @@ public function __construct(Vector $argv) { } if (array_key_exists('client-threads', $o)) { - $this->clientThreads = $this->args['client-threads']; + $this->clientThreads = $this->args['client-threads']; } if ($argTempDir === null) { @@ -564,6 +564,7 @@ private function getTargetDefinitions( 'drupal8-page-cache' => () ==> new Drupal8PageCacheTarget($this), 'drupal8-no-cache' => () ==> new Drupal8NoCacheTarget($this), 'mediawiki' => () ==> new MediaWikiTarget($this), + 'mediawiki-mlp' => () ==> new MediaWikiMLPTarget($this), 'laravel4-hello-world' => () ==> new Laravel4Target($this), 'laravel5-hello-world' => () ==> new Laravel5Target($this), 'sugarcrm-login-page' => () ==> new SugarCRMLoginPageTarget($this), diff --git a/conf/nginx/nginx.conf.in b/conf/nginx/nginx.conf.in index bef47ca..7d477e7 100644 --- a/conf/nginx/nginx.conf.in +++ b/conf/nginx/nginx.conf.in @@ -8,7 +8,7 @@ # # This file was created on: __DATE__ -worker_processes 5; +worker_processes auto; error_log __NGINX_TEMP_DIR__/nginx-error.log; pid __NGINX_PID_FILE__; @@ -21,7 +21,7 @@ http { default_type application/octet-stream; log_format main '$status $body_bytes_sent $request_time "$request"'; - + types_hash_max_size 4096; types_hash_bucket_size 64; diff --git a/targets/mediawiki/MediaWikiMLPTarget.php b/targets/mediawiki/MediaWikiMLPTarget.php new file mode 100644 index 0000000..311cf46 --- /dev/null +++ b/targets/mediawiki/MediaWikiMLPTarget.php @@ -0,0 +1,89 @@ +getSourceRoot().'/'.$fileName; + $file_contents = file_get_contents($file); + $file_contents = str_replace($search, $replace, $file_contents); + file_put_contents($file, $file_contents); + } + + public function install(): void { + $src_dir = $this->options->srcDir; + if ($src_dir) { + Utils::CopyDirContents($src_dir, $this->getSourceRoot()); + } else { + Utils::ExtractTar( + __DIR__.'/'.self::MEDIAWIKI_VERSION.'.tar.gz', + $this->options->tempDir, + ); + } + (new DatabaseInstaller($this->options)) + ->setDatabaseName('mw_bench') + ->setDumpFile(__DIR__.'/mw_bench.sql.gz') + ->installDatabase(); + + // Put it inside the source root so that if we're generating PHP files and + // we're in repo-auth mode, the generated files end up in the repo + $cache_dir = $this->getSourceRoot().'/mw-cache'; + mkdir($cache_dir); + copy(__DIR__.'/LocalSettings.php', $this->getSourceRoot().'/LocalSettings.php'); + + $this->replaceInFile('LocalSettings.php', '__DB_HOST__', $this->options->dbHost); + + file_put_contents( + $this->getSourceRoot().'/LocalSettings.php', + '$wgCacheDirectory="'.$cache_dir.'";'."\n", + FILE_APPEND, + ); + if ($this->options->useMemcached) { + copy(__DIR__.'/Memcached.php', $this->getSourceRoot().'/Memcached.php'); + $this->replaceInFile('Memcached.php', '__MEMCACHED_HOST__', '127.0.0.1'); + $this->replaceInFile('Memcached.php', '__MEMCACHED_PORT__', (string) $this->options->memcachedPort); + file_put_contents( + $this->getSourceRoot().'/LocalSettings.php', + 'require_once "'.$this->getSourceRoot().'/Memcached.php";'."\n", + FILE_APPEND, + ); + } + copy(__DIR__.'/mlp.php', $this->getSourceRoot().'/mlp.php'); + } + + <<__Override>> + public function postInstall(): void { + Utils::RunCommand( + Vector { + PHP_BINARY, + $this->getSourceRoot().'/maintenance/rebuildLocalisationCache.php', + '--lang=en', + }, + ); + } + + <<__Override>> + public function getSourceRoot(): string { + return $this->options->tempDir.'/'.self::MEDIAWIKI_VERSION; + } + + <<__Override>> + public function supportsMemcached(): bool { + return true; + } +} diff --git a/targets/mediawiki/MediaWikiMLPTarget.urls b/targets/mediawiki/MediaWikiMLPTarget.urls new file mode 100644 index 0000000..e9225f5 --- /dev/null +++ b/targets/mediawiki/MediaWikiMLPTarget.urls @@ -0,0 +1,24 @@ +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=HHVM +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page&printable=yes +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=HHVM +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page&printable=yes +http://__HTTP_HOST__:__HTTP_PORT__/mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:UserLogin +http://__HTTP_HOST__:__HTTP_PORT__/mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:RecentChanges +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:UserLogin +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page&action=history +http://__HTTP_HOST__:__HTTP_PORT__/mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=HHVM +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Talk:Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Talk:Main_Page&action=edit +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page&action=edit +http://__HTTP_HOST__:__HTTP_PORT__/mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=HHVM&action=history +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page&action=edit diff --git a/targets/mediawiki/Memcached.php b/targets/mediawiki/Memcached.php index ad4a56d..fbea6b5 100644 --- a/targets/mediawiki/Memcached.php +++ b/targets/mediawiki/Memcached.php @@ -6,3 +6,11 @@ $wgSessionCacheType = CACHE_MEMCACHED; # Turn this option back on if we use memcached $wgUseDatabaseMessages = true; + +$wgSessionsInObjectCache = true; # optional +$wgParserCacheType = CACHE_MEMCACHED; # optional +$wgMessageCacheType = CACHE_MEMCACHED; # optional +$wgLanguageConverterCacheType = CACHE_MEMCACHED; +$wgEnableSidebarCache = true; +$wgMiserMode = true; +$wgDisableCounter = true; diff --git a/targets/mediawiki/mlp.php b/targets/mediawiki/mlp.php new file mode 100644 index 0000000..ca2404d --- /dev/null +++ b/targets/mediawiki/mlp.php @@ -0,0 +1,52 @@ + { + $val1 = 'index1'; + $val2 = 'index2'; + $val3 = 'index3'; + $val4 = 'index4'; + + $hits_per_lane = $hits/5; + for ($i = 0; $i < $hits_per_lane; $i++) { + $val1 = $bigArray[$val1]; + $val2 = $bigArray[$val2]; + $val3 = $bigArray[$val3]; + $val4 = $bigArray[$val4]; + + } + return $val1.$val2.$val3.$val4; + } + +} + + +<<__EntryPoint>> +async function main(): Awaitable { + $hits = 1 * 4 * 5 * 6 * 7 * 8 * 9 * 6; + $bigArray = \apc_fetch("my-array"); + if (!$bigArray) { + $a = []; + for ($i = 0; $i < MLPChase::ARRAY_LENGTH-1; $i++) { + $i_next = $i+1; + $a['index'.\strval($i)] = 'index'.\strval($i_next); + } + $keys = \array_keys($a); + \shuffle(&$keys); + foreach ($keys as $key) { + $bigArray[$key] = $a[$key]; + } + $bigArray['index'.\strval(MLPChase::ARRAY_LENGTH-1)] = 'index0'; + \apc_add("my-array", $bigArray); + } + + $chase = new MLPChase(); + $count = await $chase->mlp( + $bigArray, + $hits, + ); + printf("%s\n",$count); + exit(0); +}