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
24 changes: 24 additions & 0 deletions base/PerfOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ final class PerfOptions {
public ?string $scriptBeforeWarmup;
public ?string $scriptAfterWarmup;
public ?string $scriptAfterBenchmark;
public ?string $hhvmServerThreads;
public ?string $benchmarkConcurrency;

public bool $notBenchmarking = false;

Expand Down Expand Up @@ -166,6 +168,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
'hhvm-server-threads:',
'benchmark-concurrency:',
};
$targets = $this->getTargetDefinitions()->keys();
$def->addAll($targets);
Expand Down Expand Up @@ -291,6 +295,26 @@ public function __construct(Vector<string> $argv) {
$this->daemonOutputToFile = $this->getBool('daemon-files');

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

if(array_key_exists('hhvm-server-threads', $o)){
$this->hhvmServerThreads = $this->getNullableString('hhvm-server-threads');
} else {
$this->hhvmServerThreads = '100';
}
$hhvmDir = realpath(__DIR__ . '/..').'/conf/php.ini';
$file_contents = file_get_contents($hhvmDir);
$file_contents = preg_replace('/^.*hhvm.server.thread_count.*$/m', 'hhvm.server.thread_count='.$this->hhvmServerThreads, $file_contents );
file_put_contents($hhvmDir, $file_contents);

if(array_key_exists('benchmark-concurrency', $o)){
$this->benchmarkConcurrency = $this->getNullableString('benchmark-concurrency');
} else {
$this->benchmarkConcurrency = '200';
}
$bmConcurrency = __DIR__.'/PerfSettings.php';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, don't modify this file.

  • nothing that modifies 'git status' is OK
  • moving it to PerfOptions is the correct thing to do.

$file_contents = file_get_contents($bmConcurrency);
$file_contents = preg_replace('/^.*Benchmark Concurrency.*$/m', ' return '.$this->benchmarkConcurrency.'; //Benchmark Concurrency *DO NOT REMOVE THIS COMMENT*', $file_contents );
file_put_contents($bmConcurrency, $file_contents);

if ($argTempDir === null) {
$this->tempDir = tempnam('/tmp', 'hhvm-nginx');
Expand Down
2 changes: 1 addition & 1 deletion base/PerfSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static function BenchmarkTime(): string {
}

public static function BenchmarkConcurrency(): int {
return 200;
return 200; //Benchmark Concurrency *DO NOT REMOVE THIS COMMENT*
}

///// Server Settings /////
Expand Down