Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Adding command line parameter to specify the number of HHVM Server Th… #80

Merged
merged 9 commits into from
Mar 22, 2017
1 change: 1 addition & 0 deletions base/HHVMDaemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ protected function getArguments(): Vector<string> {
if (count($this->options->hhvmExtraArguments) > 0) {
$args->addAll($this->options->hhvmExtraArguments);
}
$args->add('-dhhvm.server.thread_count='.$this->options->serverThreads);
if ($this->options->precompile) {
$bcRepo = $this->options->tempDir.'/hhvm.hhbc';
$args->add('-v');
Expand Down
5 changes: 5 additions & 0 deletions base/PHP5Daemon.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ protected function getArguments(): Vector<string> {
PerfSettings::BackendPort(),
$config
);
$config = str_replace(
"__CHILDREN__",
$this->options->serverThreads,
$config
);
$config = str_replace(
"__TMP_DIR__",
$this->options->tempDir,
Expand Down
13 changes: 12 additions & 1 deletion base/PerfOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ final class PerfOptions {
public ?string $scriptBeforeWarmup;
public ?string $scriptAfterWarmup;
public ?string $scriptAfterBenchmark;
public string $serverThreads = '100';
public string $clientThreads = '200';

public bool $notBenchmarking = false;

Expand Down Expand Up @@ -181,6 +183,8 @@ public function __construct(Vector<string> $argv) {
'daemon-files', // daemon output goes to files in the temp directory
'temp-dir:', // temp directory to use; if absent one in /tmp is made
'src-dir:', // location for source to copy into tmp dir instead of ZIP
'server-threads:',
'client-threads:',
};
$targets = $this->getTargetDefinitions()->keys();
$def->addAll($targets);
Expand Down Expand Up @@ -320,7 +324,15 @@ public function __construct(Vector<string> $argv) {
$this->daemonOutputToFile = $this->getBool('daemon-files');

$argTempDir = $this->getNullableString('temp-dir');

if(array_key_exists('server-threads', $o)){
$this->serverThreads = $this->args['server-threads'];
}

if(array_key_exists('client-threads', $o)){
$this->clientThreads = $this->args['client-threads'];
}

if ($argTempDir === null) {
$this->tempDir = tempnam('/tmp', 'hhvm-nginx');
// Currently a file - change to a dir
Expand All @@ -331,7 +343,6 @@ public function __construct(Vector<string> $argv) {
}

$this->srcDir = $this->getNullableString('src-dir');

}

public function validate() {
Expand Down
4 changes: 0 additions & 4 deletions base/PerfSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public static function BenchmarkTime(): string {
return '1M'; // 1 minute
}

public static function BenchmarkConcurrency(): int {
return 200;
}

///// Server Settings /////

public static function HttpPort(): int {
Expand Down
4 changes: 2 additions & 2 deletions base/Siege.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function getArguments(): Vector<string> {
$arguments->addAll(
Vector {
'-c',
(string) PerfSettings::BenchmarkConcurrency(),
$this->options->clientThreads,
'-t',
'1M',
'-f',
Expand All @@ -146,7 +146,7 @@ protected function getArguments(): Vector<string> {
$arguments->addAll(
Vector {
'-c',
(string) PerfSettings::BenchmarkConcurrency(),
$this->options->clientThreads,
'-f',
$urls_file,
'--benchmark',
Expand Down
2 changes: 1 addition & 1 deletion conf/php-fpm.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ listen.allowed_clients = 127.0.0.1
pm = static

; The number of child processes to be created when pm is set to 'static'
pm.max_children = 100
pm.max_children = __CHILDREN__
3 changes: 0 additions & 3 deletions conf/php.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ assert.active=false
;;;;;;;;;;;;;
; HHVM Only ;
;;;;;;;;;;;;;
; HHVM's default is 2*CPU cores; this works reasonably well if you're using
; HHVM's async features, however it's way too low for most other loads.
hhvm.server.thread_count=100
; This is a no-op on production builds, but makes it possible to get meaningful
; profiles from debug builds
hhvm.hhir_generate_asserts=0
Expand Down