From 6f016ff7eddfe759aac584cf1802cf513728da4a Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 14 Sep 2023 17:48:44 +0200 Subject: [PATCH] Upload callgrind profile to GA --- .github/workflows/push.yml | 5 +++++ benchmark/.gitignore | 1 + benchmark/benchmark.php | 20 ++++++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 60a5988398daf..fa3ea84f7b91c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -288,3 +288,8 @@ jobs: ${{ github.sha }} \ $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.sha }}) \ > $GITHUB_STEP_SUMMARY + - uses: actions/upload-artifact@v3 + with: + name: profiles + path: ${{ github.workspace }}/benchmark/profiles + retention-days: 30 diff --git a/benchmark/.gitignore b/benchmark/.gitignore index cc2bbd2422f01..e1aa448e597b7 100644 --- a/benchmark/.gitignore +++ b/benchmark/.gitignore @@ -1 +1,2 @@ +/profiles /repos diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index a838d4c4f80d4..a0c01ca766233 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -12,6 +12,11 @@ function main() { global $storeResult; + $profilesDir = __DIR__ . '/profiles'; + if (!is_dir($profilesDir)) { + mkdir($profilesDir, 0755, true); + } + $data = []; if (false !== $branch = getenv('GITHUB_REF_NAME')) { $data['branch'] = $branch; @@ -50,7 +55,7 @@ function getPhpSrcCommitHash(): string { } function runBench(bool $jit): array { - return runValgrindPhpCgiCommand([dirname(__DIR__) . '/Zend/bench.php'], jit: $jit); + return runValgrindPhpCgiCommand('bench', [dirname(__DIR__) . '/Zend/bench.php'], jit: $jit); } function runSymfonyDemo(bool $jit): array { @@ -58,7 +63,7 @@ function runSymfonyDemo(bool $jit): array { cloneRepo($dir, 'https://github.com/php/benchmarking-symfony-demo-2.2.3.git'); runPhpCommand([$dir . '/bin/console', 'cache:clear']); runPhpCommand([$dir . '/bin/console', 'cache:warmup']); - return runValgrindPhpCgiCommand([$dir . '/public/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50); + return runValgrindPhpCgiCommand('symfony-demo', [$dir . '/public/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50); } function runWordpress(bool $jit): array { @@ -81,7 +86,7 @@ function runWordpress(bool $jit): array { // Warmup runPhpCommand([$dir . '/index.php'], $dir); - return runValgrindPhpCgiCommand([$dir . '/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50); + return runValgrindPhpCgiCommand('wordpress', [$dir . '/index.php'], cwd: $dir, jit: $jit, warmup: 50, repeat: 50); } function runPhpCommand(array $args, ?string $cwd = null): ProcessResult { @@ -89,6 +94,7 @@ function runPhpCommand(array $args, ?string $cwd = null): ProcessResult { } function runValgrindPhpCgiCommand( + string $name, array $args, ?string $cwd = null, bool $jit = false, @@ -96,11 +102,17 @@ function runValgrindPhpCgiCommand( int $repeat = 1, ): array { global $phpCgi; + + $profileOut = __DIR__ . "/profiles/callgrind.out.$name"; + if ($jit) { + $profileOut .= '.jit'; + } + $process = runCommand([ 'valgrind', '--tool=callgrind', '--dump-instr=yes', - '--callgrind-out-file=/dev/null', + "--callgrind-out-file=$profileOut", '--', $phpCgi, '-T' . ($warmup ? $warmup . ',' : '') . $repeat,