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 Memcached support for the MediaWiki target
This diff adds support for Memcached. If a target supports Memcached, oss-performance will start it on 127.0.0.1:11888. The only target supporting Memcached right now is MediaWiki. For other targets to support Memcached, they must override PerfTarget::supportsMemcached(). This diff also sets $wgUseDatabaseMessages to false in the configuration file if Memcached is disabled, as recommended in the MediaWiki manual. For MediaWiki with Memcached enabled, observing a ~6% increase in RPS, a decrease in system idle time, as well as ~7 percentage points more cycles being spent in HHVM. Command line options added: --memcached: path to memcached binary --delay-memcached-startup: number of seconds to delay Memcached startup --memcached-port: TCP port to listen on (default is 11888) --no-memcached: don't use memcached (even if target supports it) --memcached-threads: number of memcached threads to spawn (default is 4 for machines with small number of cores, 32 otherwise)
- Loading branch information
Showing
8 changed files
with
145 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?hh | ||
/* | ||
* Copyright (c) 2017, Facebook, Inc. | ||
* All rights reserved. | ||
* | ||
* This source code is licensed under the BSD-style license found in the | ||
* LICENSE file in the root directory of this source tree. An additional grant | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
*/ | ||
final class MemcachedDaemon extends Process { | ||
|
||
private int $maxMemory = 2048; | ||
|
||
public function __construct( | ||
private PerfOptions $options, | ||
private PerfTarget $target, | ||
) { | ||
parent::__construct($this->options->memcached); | ||
} | ||
|
||
public function start(): void { | ||
parent::startWorker( | ||
$this->options->daemonOutputFileName('memcached'), | ||
$this->options->delayProcessLaunch, | ||
$this->options->traceSubProcess, | ||
); | ||
} | ||
|
||
public function getNumThreads(): int { | ||
$output = []; | ||
$ret = -1; | ||
if ($this->options->memcachedThreads != 0) { | ||
return $this->options->memcachedThreads; | ||
} | ||
|
||
exec('nproc', $output, $ret); | ||
if ($ret != 0) { | ||
invariant_violation('%s', 'Execution of nproc failed'); | ||
exit(1); | ||
} | ||
$numProcs = (int)($output[0]); | ||
|
||
// for small number of cores, use the default, which is 4; | ||
// otherwise, we probably need more | ||
if ($numProcs <= 8) | ||
return 4; | ||
|
||
return 32; | ||
} | ||
|
||
<<__Override>> | ||
protected function getPidFilePath(): string { | ||
return $this->options->tempDir.'/memcached.pid'; | ||
} | ||
|
||
<<__Override>> | ||
protected function getArguments(): Vector<string> { | ||
if ($this->options->cpuBind) { | ||
$this->cpuRange = $this->options->helperProcessors; | ||
} | ||
return Vector { | ||
'-m', | ||
(string) $this->maxMemory, | ||
'-l', | ||
'127.0.0.1', | ||
'-t', | ||
(string) $this->getNumThreads(), | ||
'-p', | ||
(string) $this->options->memcachedPort, | ||
'-P', # pid file | ||
$this->getPidFilePath() | ||
}; | ||
} | ||
} |
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
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
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,8 @@ | ||
<?php | ||
|
||
$wgMainCacheType = CACHE_MEMCACHED; | ||
$wgMemCachedServers = array( "__MEMCACHED_HOST__:__MEMCACHED_PORT__" ); | ||
|
||
$wgSessionCacheType = CACHE_MEMCACHED; | ||
# Turn this option back on if we use memcached | ||
$wgUseDatabaseMessages = true; |