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

Commit

Permalink
Parameters for running scripts/commands at specific times.
Browse files Browse the repository at this point in the history
Added three parameters for running scripts/commands before warmup, after warmup
and after benchmark.
Internally we use these parameters to profile HHVM using VTune/perf or to
regenerate the oss hot section ordering file.

Example for running VTune:
perf.php --wordpress  \
	 --i-am-not-benchmarking \
	 --exec-after-warmup="amplxe-cl \
		-collect advanced-hotspots  \
		--analyze-system \
		--d 60 > dmp_vtune.txt &" \
	 --hhvm=$HHVM_PATH
  • Loading branch information
andreeaflorescu committed Jan 25, 2016
1 parent 1d6662f commit 8f0f0b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions base/PerfOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ final class PerfOptions {
public string $tempDir;
public ?string $srcDir;

public ?string $scriptBeforeWarmup;
public ?string $scriptAfterWarmup;
public ?string $scriptAfterBenchmark;

public bool $notBenchmarking = false;

private array $args;
Expand Down Expand Up @@ -156,6 +160,9 @@ public function __construct(Vector<string> $argv) {
'max-delay-admin-request:',
'max-delay-nginx-keepalive:',
'max-delay-nginx-fastcgi:',
'exec-before-warmup:',
'exec-after-warmup:',
'exec-after-benchmark:',
'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
Expand Down Expand Up @@ -235,6 +242,10 @@ public function __construct(Vector<string> $argv) {
$this->allVolatile = $this->getBool('all-volatile');
$this->interpPseudomains = $this->getBool('interp-pseudomains');

$this->scriptBeforeWarmup = $this->getNullableString('exec-before-warmup');
$this->scriptAfterWarmup = $this->getNullableString('exec-after-warmup');
$this->scriptAfterBenchmark = $this->getNullableString('exec-after-benchmark');

if ($this->getBool('tcprint')) {
$tcprint = hphp_array_idx($o, 'tcprint', null);
if (is_string($tcprint) && $tcprint !== '') {
Expand Down
15 changes: 15 additions & 0 deletions base/PerfRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ private static function RunWithOptionsAndEngine(
$target->sanityCheck();
}

if ($options->scriptBeforeWarmup !== null) {
self::PrintProgress('Starting execution of command: '.$options->scriptBeforeWarmup);
exec($options->scriptBeforeWarmup);
}

if (!$options->skipWarmUp) {
self::PrintProgress('Starting Siege for single request warmup');
$siege = new Siege($options, $target, RequestModes::WARMUP);
Expand Down Expand Up @@ -139,12 +144,22 @@ private static function RunWithOptionsAndEngine(
fread(STDIN, 1);
}

if ($options->scriptAfterWarmup !== null) {
self::PrintProgress('Starting execution of command: '.$options->scriptAfterWarmup);
exec($options->scriptAfterWarmup);
}

self::PrintProgress('Starting Siege for benchmark');
$siege = new Siege($options, $target, RequestModes::BENCHMARK);
$siege->start();
invariant($siege->isRunning(), 'Siege failed to start');
$siege->wait();

if ($options->scriptAfterBenchmark !== null) {
self::PrintProgress('Starting execution of command: '.$options->scriptAfterBenchmark);
exec($options->scriptAfterBenchmark);
}

self::PrintProgress('Collecting results');

$combined_stats = Map {};
Expand Down

0 comments on commit 8f0f0b0

Please sign in to comment.