This repository has been archived by the owner on Jan 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add MLP target, a memory intensive variation of MediaWiki
- Loading branch information
Showing
6 changed files
with
177 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?hh | ||
/* | ||
* Copyright (c) 2014-present, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
*/ | ||
|
||
final class MediaWikiMLPTarget extends PerfTarget { | ||
|
||
const MEDIAWIKI_VERSION = 'mediawiki-1.28.0'; | ||
|
||
public function __construct(private PerfOptions $options) {} | ||
|
||
protected function getSanityCheckString(): string { | ||
return 'Obama'; | ||
} | ||
|
||
private function replaceInFile(string $fileName, string $search, string $replace) { | ||
$file = $this->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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?hh // strict | ||
|
||
class MLPChase { | ||
const ARRAY_LENGTH = 1 << 22; | ||
|
||
async public function mlp(array $bigArray, int $hits): Awaitable<string> { | ||
$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<void> { | ||
$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); | ||
} |