diff --git a/base/PerfOptions.php b/base/PerfOptions.php index f0ce292..426d57c 100644 --- a/base/PerfOptions.php +++ b/base/PerfOptions.php @@ -568,6 +568,7 @@ private function getTargetDefinitions( 'drupal8-no-cache' => () ==> new Drupal8NoCacheTarget($this), 'mediawiki' => () ==> new MediaWikiTarget($this), 'mediawiki-mlp' => () ==> new MediaWikiMLPTarget($this), + 'mediawiki-mem' => () ==> new MediaWikiMemTarget($this), 'laravel4-hello-world' => () ==> new Laravel4Target($this), 'laravel5-hello-world' => () ==> new Laravel5Target($this), 'sugarcrm-login-page' => () ==> new SugarCRMLoginPageTarget($this), diff --git a/targets/mediawiki/MediaWikiMemTarget.php b/targets/mediawiki/MediaWikiMemTarget.php new file mode 100644 index 0000000..29573b6 --- /dev/null +++ b/targets/mediawiki/MediaWikiMemTarget.php @@ -0,0 +1,90 @@ +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__', 'localhost'); + $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__.'/mem_mlp.php', $this->getSourceRoot().'/mem_mlp.php'); + copy(__DIR__.'/lambdachase.php', $this->getSourceRoot().'/lambdachase.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/MediaWikiMemTarget.urls b/targets/mediawiki/MediaWikiMemTarget.urls new file mode 100644 index 0000000..a106931 --- /dev/null +++ b/targets/mediawiki/MediaWikiMemTarget.urls @@ -0,0 +1,140 @@ +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_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__/mem_mlp.php +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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Talk:Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=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 +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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +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__/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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.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__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:UserLogin +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/mem_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=Main_Page +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=Talk:Main_Page +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=HHVM&action=history +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=Main_Page&action=history +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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=HHVM +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 +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.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=Main_Page +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__/lambdachase.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=Main_Page +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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page&action=edit +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:UserLogin +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:RecentChanges +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__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=HHVM +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.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__/lambdachase.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=Main_Page&printable=yes +http://__HTTP_HOST__:__HTTP_PORT__/mem_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=Talk:Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/mem_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=Main_Page +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=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.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__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:RecentChanges +http://__HTTP_HOST__:__HTTP_PORT__/mem_mlp.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=HHVM +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.php +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/lambdachase.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=Talk:Main_Page +http://__HTTP_HOST__:__HTTP_PORT__/index.php?title=Special:UserLogin diff --git a/targets/mediawiki/lambdachase.php b/targets/mediawiki/lambdachase.php new file mode 100644 index 0000000..83fe824 --- /dev/null +++ b/targets/mediawiki/lambdachase.php @@ -0,0 +1,56 @@ + { + $m = dict[]; + for ($i = 0; $i < self::NUM_LAMBDAS-1; $i++) { + $key = "lambda".\strval($i); + $next = "lambda".\strval($i+1); + $m[$key] = self::lambda($next); + $m["num".\strval($i)] = vec[$i]; + } + $key = "lambda".\strval(self::NUM_LAMBDAS - 1); + $next = "lambda0"; + $m[$key] = self::lambda($next); + return $m; + } + + public static function lambda(string $s): (function (string): string) { + return function(string $x): string use ($s) { return $s; }; + } + +} + +class LambdaChase { + const CHASE_COUNT = 40000; + + public function helloWorld(): string { + return 'Hello, world!'; + } + + public function go(): int { + $count = 0; + $next_f = "lambda0"; + $lambdas = Lambdas::getLambdas(); + for ($i = 1; $i < LambdaChase::CHASE_COUNT; ++$i) { + $f = $lambdas[$next_f]; + $next_f = $f($next_f); + $f = $lambdas[$next_f]; + $next_f = $f($next_f); + $f = $lambdas[$next_f]; + $next_f = $f($next_f); + $count += 3; + } + return $count; + } +} + +<<__EntryPoint>> +async function main(): Awaitable { + $chase = new LambdaChase(); + printf("%s\n", $chase->helloWorld()); + printf("%d\n", $chase->go()); + exit(0); +} diff --git a/targets/mediawiki/mem_mlp.php b/targets/mediawiki/mem_mlp.php new file mode 100644 index 0000000..1390e40 --- /dev/null +++ b/targets/mediawiki/mem_mlp.php @@ -0,0 +1,71 @@ + { + $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; + $arrayIdx = rand(1, 30); + $arrayName = "big-array-".\strval($arrayIdx); + printf("%s\n",$arrayName); + $bigArray = \apc_fetch($arrayName); + if (!$bigArray) { + $tagName = "array-tag-".\strval($arrayIdx); + $arrayTag = \apc_fetch($tagName); + if ($arrayTag) { + exit(0); + } else { + $backoffTime = 1000 * rand(1, 1000); + usleep($backoffTime); + $arrayTag = \apc_fetch($tagName); + if ($arrayTag) { + exit(0); + } + } + \apc_add($tagName, $arrayName); + $a = []; + for ($i = 0; $i < MemMLPChase::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(MemMLPChase::ARRAY_LENGTH-1)] = 'index0'; + \apc_add($arrayName, $bigArray); + } + + $chase = new MemMLPChase(); + $count = await $chase->mlp( + $bigArray, + $hits, + ); + printf("%s\n",$count); + exit(0); +} diff --git a/targets/mediawiki/mlp.php b/targets/mediawiki/mlp.php index ca2404d..fb7a40b 100644 --- a/targets/mediawiki/mlp.php +++ b/targets/mediawiki/mlp.php @@ -41,10 +41,10 @@ class MLPChase { $bigArray['index'.\strval(MLPChase::ARRAY_LENGTH-1)] = 'index0'; \apc_add("my-array", $bigArray); } - + $chase = new MLPChase(); $count = await $chase->mlp( - $bigArray, + $bigArray, $hits, ); printf("%s\n",$count);