From d4ac30ff2154ecb2b97a5a916efc25272ed8da10 Mon Sep 17 00:00:00 2001 From: kevand900 Date: Wed, 22 Mar 2017 10:26:49 -0700 Subject: [PATCH] =?UTF-8?q?Adding=20command=20line=20parameter=20to=20spec?= =?UTF-8?q?ify=20the=20number=20of=20HHVM=20Server=20Th=E2=80=A6=20(#80)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Adding command line parameters to change the number of hhvm server threads as well as the benchmark concurrency. In order to use these options they must be paired with '--i-am-not-benchmarking' For HHVM Server Threads use: --hhvm-server-threads= The default is 100 For Benchmark Concurrency use: --benchmark-concurrency= The default is 200 * Adding command line parameter to specify the number of HHVM Server Threads as well as Benchmark Concurrency. These options are to be paired with '--i-am-not-benchmarking' For HHVM Server threads: --hhvm-server-threads= Default is 100 For Benchmark Concurrency --benchmark-concurrency= Default is 200 * Adding command line parameters to specify the number of ServerThreads (--server-threads=) and the BenchmarkConcurrency (--benchmark-concurrency=). Revising the method that these are set, using a setter method in PerfSettings.php for the BenchmarkConcurrency, set from PerfOptions.php. For ServerThreads we append the dhhvm.server.thread_count to the hhvmExtraArguments array. This is just a wrapper for the optional method of specifying via --hhvm-extra-arguments=-dhhvm.server.thread_count=. * Made it so we do not have to use --i-am-not-benchmarking for --server-threads and --client-threads. * Resolved review comments. * Resolving requested changes. * Resolving requested changes, made pm.max_children variable. --- base/HHVMDaemon.php | 1 + base/PHP5Daemon.php | 5 +++++ base/PerfOptions.php | 13 ++++++++++++- base/PerfSettings.php | 4 ---- base/Siege.php | 4 ++-- conf/php-fpm.conf.in | 2 +- conf/php.ini | 3 --- 7 files changed, 21 insertions(+), 11 deletions(-) diff --git a/base/HHVMDaemon.php b/base/HHVMDaemon.php index 630c056..3a354d6 100644 --- a/base/HHVMDaemon.php +++ b/base/HHVMDaemon.php @@ -118,6 +118,7 @@ protected function getArguments(): Vector { 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'); diff --git a/base/PHP5Daemon.php b/base/PHP5Daemon.php index 48ab27f..faa73ca 100644 --- a/base/PHP5Daemon.php +++ b/base/PHP5Daemon.php @@ -84,6 +84,11 @@ protected function getArguments(): Vector { PerfSettings::BackendPort(), $config ); + $config = str_replace( + "__CHILDREN__", + $this->options->serverThreads, + $config + ); $config = str_replace( "__TMP_DIR__", $this->options->tempDir, diff --git a/base/PerfOptions.php b/base/PerfOptions.php index a09e655..789c478 100644 --- a/base/PerfOptions.php +++ b/base/PerfOptions.php @@ -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; @@ -181,6 +183,8 @@ public function __construct(Vector $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); @@ -320,7 +324,15 @@ public function __construct(Vector $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 @@ -331,7 +343,6 @@ public function __construct(Vector $argv) { } $this->srcDir = $this->getNullableString('src-dir'); - } public function validate() { diff --git a/base/PerfSettings.php b/base/PerfSettings.php index 0452eea..b222c36 100644 --- a/base/PerfSettings.php +++ b/base/PerfSettings.php @@ -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 { diff --git a/base/Siege.php b/base/Siege.php index 89ab14d..d8ae674 100644 --- a/base/Siege.php +++ b/base/Siege.php @@ -132,7 +132,7 @@ protected function getArguments(): Vector { $arguments->addAll( Vector { '-c', - (string) PerfSettings::BenchmarkConcurrency(), + $this->options->clientThreads, '-t', '1M', '-f', @@ -146,7 +146,7 @@ protected function getArguments(): Vector { $arguments->addAll( Vector { '-c', - (string) PerfSettings::BenchmarkConcurrency(), + $this->options->clientThreads, '-f', $urls_file, '--benchmark', diff --git a/conf/php-fpm.conf.in b/conf/php-fpm.conf.in index abb3a64..5f8132f 100644 --- a/conf/php-fpm.conf.in +++ b/conf/php-fpm.conf.in @@ -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__ diff --git a/conf/php.ini b/conf/php.ini index 56d3c7a..a4dc59e 100644 --- a/conf/php.ini +++ b/conf/php.ini @@ -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