From 0d31d89de53fde4d87ff1b7fec03e454ca9056b0 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 6 Apr 2023 19:29:34 +0200 Subject: [PATCH 01/11] Add benchmarking to CI --- .github/workflows/push.yml | 74 +++++++++++++++++++++++ benchmark/.gitignore | 1 + benchmark/benchmark.php | 112 +++++++++++++++++++++++++++++++++++ benchmark/docker-compose.yml | 11 ++++ benchmark/generate_diff.php | 63 ++++++++++++++++++++ benchmark/shared.php | 72 ++++++++++++++++++++++ 6 files changed, 333 insertions(+) create mode 100644 benchmark/.gitignore create mode 100644 benchmark/benchmark.php create mode 100644 benchmark/docker-compose.yml create mode 100644 benchmark/generate_diff.php create mode 100644 benchmark/shared.php diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 65cdf72f3caf3..980a7d71ae51a 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -215,3 +215,77 @@ jobs: run: .github/scripts/windows/build.bat - name: Test run: .github/scripts/windows/test.bat + BENCHMARKING: + name: BENCHMARKING + runs-on: ubuntu-22.04 + steps: + - name: git checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: apt + run: | + set -x + sudo apt-get update + sudo apt-get install \ + bison \ + re2c \ + locales \ + openssl \ + language-pack-de \ + libsqlite3-dev \ + libonig-dev \ + libc-client-dev \ + valgrind + - name: ccache + uses: hendrikmuhs/ccache-action@v1.2 + with: + key: "${{github.job}}-${{hashFiles('main/php_version.h')}}" + append-timestamp: false + - name: ./configure + run: | + set -x + ./buildconf --force + ./configure \ + --disable-debug \ + --with-valgrind \ + --enable-opcache \ + --enable-option-checking=fatal \ + --prefix=/usr \ + --with-config-file-scan-dir=/etc/php.d \ + --with-mysqli=mysqlnd \ + --with-pdo-sqlite \ + --enable-mbstring \ + --enable-sockets \ + --with-openssl \ + --enable-werror + - name: make + run: make -j$(/usr/bin/nproc) >/dev/null + - name: make install + uses: ./.github/actions/install-linux + - name: Prepare SSH key + run: | + mkdir -p ~/.ssh + echo "${{ secrets.BENCHMARK_DATA_DEPLOY_KEY }}" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + git config --global user.name "Benchmark" + git config --global user.email "benchmark@php.net" + - name: Setup + run: | + sudo service mysql start + mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" + mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" + mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" + mkdir -p /etc/php.d + echo zend_extension=opcache.so >> /etc/php.d/opcache.ini + echo opcache.enable=1 >> /etc/php.d/opcache.ini + echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini + - name: Benchmark + run: php benchmark/benchmark.php true + - name: Show diff + if: github.event_name == 'pull_request' + run: >- + php benchmark/generate_diff.php + ${{ github.event.pull_request.head.sha }} + $(git merge-base ${{ github.base_ref }} ${{ github.head_ref }}) + > $GITHUB_STEP_SUMMARY diff --git a/benchmark/.gitignore b/benchmark/.gitignore new file mode 100644 index 0000000000000..cc2bbd2422f01 --- /dev/null +++ b/benchmark/.gitignore @@ -0,0 +1 @@ +/repos diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php new file mode 100644 index 0000000000000..cd8117328c1d1 --- /dev/null +++ b/benchmark/benchmark.php @@ -0,0 +1,112 @@ +'], $repo); + runCommand(['git', 'push'], $repo); +} + +function getPhpSrcCommitHash(): string { + $result = runCommand(['git', 'log', '--pretty=format:%H', '-n', '1'], dirname(__DIR__)); + return $result->stdout; +} + +function runBench(): array { + $process = runValgrindPhpCgiCommand([dirname(__DIR__) . '/Zend/bench.php']); + return ['instructions' => extractInstructionsFromValgrindOutput($process->stderr)]; +} + +function runSymfonyDemo(): array { + $dir = __DIR__ . '/repos/symfony-demo-2.2.3'; + cloneRepo($dir, 'git@github.com:iluuu1994/symfony-demo-2.2.3.git'); + runPhpCommand([$dir . '/bin/console', 'cache:clear']); + runPhpCommand([$dir . '/bin/console', 'cache:warmup']); + $process = runValgrindPhpCgiCommand(['-T1,1', $dir . '/public/index.php']); + return ['instructions' => extractInstructionsFromValgrindOutput($process->stderr)]; +} + +function runWordpress(): array { + $dir = __DIR__ . '/repos/wordpress-6.2'; + cloneRepo($dir, 'git@github.com:iluuu1994/wordpress-6.2.git'); + + /* FIXME: It might be better to use a stable version of PHP for this command because we can't + * easily alter the phar file */ + runPhpCommand([ + '-d error_reporting=0', + 'wp-cli.phar', + 'core', + 'install', + '--url=wordpress.local', + '--title="Wordpress"', + '--admin_user=wordpress', + '--admin_password=wordpress', + '--admin_email=benchmark@php.net', + ], $dir); + + // Warmup + runPhpCommand([$dir . '/index.php'], $dir); + $process = runValgrindPhpCgiCommand(['-T1,1', $dir . '/index.php'], $dir); + return ['instructions' => extractInstructionsFromValgrindOutput($process->stderr)]; +} + +function runPhpCommand(array $args, ?string $cwd = null): ProcessResult { + return runCommand([PHP_BINARY, ...$args], $cwd); +} + +function runValgrindPhpCgiCommand(array $args, ?string $cwd = null): ProcessResult { + global $phpCgi; + return runCommand([ + 'valgrind', + '--tool=callgrind', + '--dump-instr=yes', + '--callgrind-out-file=/dev/null', + '--', + $phpCgi, + '-d max_execution_time=0', + ...$args, + ]); +} + +function extractInstructionsFromValgrindOutput(string $output): ?string { + preg_match("(==[0-9]+== Events : Ir\n==[0-9]+== Collected : (?[0-9]+))", $output, $matches); + return $matches['instructions'] ?? null; +} + +main(); diff --git a/benchmark/docker-compose.yml b/benchmark/docker-compose.yml new file mode 100644 index 0000000000000..6d62806d355b3 --- /dev/null +++ b/benchmark/docker-compose.yml @@ -0,0 +1,11 @@ +version: "3.8" +services: + wordpress_db: + image: mysql:8.0 + ports: + - "3306:3306" + environment: + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: wordpress + MYSQL_USER: wordpress + MYSQL_PASSWORD: wordpress diff --git a/benchmark/generate_diff.php b/benchmark/generate_diff.php new file mode 100644 index 0000000000000..2bfd50e05d3db --- /dev/null +++ b/benchmark/generate_diff.php @@ -0,0 +1,63 @@ + $headBenchmark) { + $baseInstructions = $baseSummary[$name]['instructions'] ?? null; + $headInstructions = $headSummary[$name]['instructions']; + $output .= "| $name | " + . formatInstructions($baseInstructions) . " | " + . formatInstructions($headInstructions) . " | " + . formatDiff($baseInstructions, $headInstructions) . " |\n"; + } + return $output; +} + +function formatInstructions(?int $instructions): string { + if ($instructions === null) { + return '-'; + } + if ($instructions > 1e6) { + return sprintf('%.0fM', $instructions / 1e6); + } elseif ($instructions > 1e3) { + return sprintf('%.0fK', $instructions / 1e3); + } else { + return (string) $instructions; + } +} + +function formatDiff(?int $baseInstructions, int $headInstructions): string { + if ($baseInstructions === null) { + return '-'; + } + $instructionDiff = $headInstructions - $baseInstructions; + return sprintf('%.2f%%', $instructionDiff / $baseInstructions * 100); +} + +$headCommitHash = $argv[1] ?? null; +$baseCommitHash = $argv[2] ?? null; +$output = main($headCommitHash, $baseCommitHash); +fwrite(STDOUT, $output); diff --git a/benchmark/shared.php b/benchmark/shared.php new file mode 100644 index 0000000000000..450101770b28b --- /dev/null +++ b/benchmark/shared.php @@ -0,0 +1,72 @@ + ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']]; + fwrite(STDOUT, "> $cmd\n"); + $processHandle = proc_open($cmd, $descriptorSpec, $pipes, $cwd ?? getcwd(), null); + + $stdin = $pipes[0]; + $stdout = $pipes[1]; + $stderr = $pipes[2]; + + fclose($stdin); + + stream_set_blocking($stdout, false); + stream_set_blocking($stderr, false); + + $stdoutEof = false; + $stderrEof = false; + + do { + $read = [$stdout, $stderr]; + $write = null; + $except = null; + + stream_select($read, $write, $except, 1, 0); + + foreach ($read as $stream) { + $chunk = fgets($stream); + if ($stream === $stdout) { + $result->stdout .= $chunk; + } elseif ($stream === $stderr) { + $result->stderr .= $chunk; + } + } + + $stdoutEof = $stdoutEof || feof($stdout); + $stderrEof = $stderrEof || feof($stderr); + } while(!$stdoutEof || !$stderrEof); + + fclose($stdout); + fclose($stderr); + + $statusCode = proc_close($processHandle); + if ($statusCode !== 0) { + fwrite(STDOUT, $result->stdout); + fwrite(STDERR, $result->stderr); + fwrite(STDERR, 'Exited with status code ' . $statusCode . "\n"); + exit($statusCode); + } + + return $result; +} + +function cloneRepo(string $path, string $url) { + if (is_dir($path)) { + return; + } + $dir = dirname($path); + $repo = basename($path); + if (!is_dir($dir)) { + mkdir($dir, 0755, true); + } + runCommand(['git', 'clone', '-q', '--end-of-options', $url, $repo], dirname($path)); +} From c16eb2719f91abc8d0dc892e52877bf44ba50d5c Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 13 Apr 2023 14:47:04 +0200 Subject: [PATCH 02/11] Fix issues --- .github/workflows/push.yml | 24 ++++++++++++++++++------ benchmark/benchmark.php | 23 +++++++++-------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 980a7d71ae51a..ba24465fe6efd 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -223,6 +223,12 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 + - name: git checkout benchmarking-data + uses: actions/checkout@v3 + with: + repository: iluuu1994/php-benchmark-data + ssh-key: ${{ secrets.BENCHMARK_DATA_DEPLOY_KEY }} + path: benchmark/repos/data - name: apt run: | set -x @@ -263,15 +269,10 @@ jobs: run: make -j$(/usr/bin/nproc) >/dev/null - name: make install uses: ./.github/actions/install-linux - - name: Prepare SSH key + - name: Setup run: | - mkdir -p ~/.ssh - echo "${{ secrets.BENCHMARK_DATA_DEPLOY_KEY }}" > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 git config --global user.name "Benchmark" git config --global user.email "benchmark@php.net" - - name: Setup - run: | sudo service mysql start mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" @@ -282,6 +283,17 @@ jobs: echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini - name: Benchmark run: php benchmark/benchmark.php true + - name: Store result + if: github.event_name == 'push' + run: | + set -x + cd benchmark/repos/data + git add . + if git diff --cached --quiet; then + exit 0 + fi + git commit -m "Add result for ${{ github.repository }}@${{ steps.determine-commit.outputs.sha }}" + git push - name: Show diff if: github.event_name == 'pull_request' run: >- diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index cd8117328c1d1..e7b0d7718e1cc 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -2,7 +2,7 @@ require_once __DIR__ . '/shared.php'; -$commitResult = ($argv[1] ?? 'false') === 'true'; +$storeResult = ($argv[1] ?? 'false') === 'true'; $phpCgi = $argv[2] ?? dirname(PHP_BINARY) . '/php-cgi'; if (!file_exists($phpCgi)) { fwrite(STDERR, "php-cgi not found\n"); @@ -10,7 +10,7 @@ } function main() { - global $commitResult; + global $storeResult; $data = []; $data['bench.php'] = runBench(); @@ -18,17 +18,16 @@ function main() { $data['wordpress_6.2'] = runWordpress(); $result = json_encode($data, JSON_PRETTY_PRINT) . "\n"; - if ($commitResult) { - commitResult($result); - } else { - fwrite(STDOUT, $result); + fwrite(STDOUT, $result); + + if ($storeResult) { + storeResult($result); } } -function commitResult(string $result) { +function storeResult(string $result) { $repo = __DIR__ . '/repos/data'; cloneRepo($repo, 'git@github.com:iluuu1994/php-benchmark-data.git'); - runCommand(['git', 'pull', '--end-of-options', 'origin'], $repo); $commitHash = getPhpSrcCommitHash(); $dir = $repo . '/' . substr($commitHash, 0, 2) . '/' . $commitHash; @@ -37,10 +36,6 @@ function commitResult(string $result) { mkdir($dir, 0755, true); } file_put_contents($summaryFile, $result); - - runCommand(['git', 'add', '--end-of-options', $summaryFile], $repo); - runCommand(['git', 'commit', '--allow-empty', '-m', 'Add result for php/php-src@' . $commitHash, '--author', 'Benchmark '], $repo); - runCommand(['git', 'push'], $repo); } function getPhpSrcCommitHash(): string { @@ -55,7 +50,7 @@ function runBench(): array { function runSymfonyDemo(): array { $dir = __DIR__ . '/repos/symfony-demo-2.2.3'; - cloneRepo($dir, 'git@github.com:iluuu1994/symfony-demo-2.2.3.git'); + cloneRepo($dir, 'https://github.com/iluuu1994/symfony-demo-2.2.3.git'); runPhpCommand([$dir . '/bin/console', 'cache:clear']); runPhpCommand([$dir . '/bin/console', 'cache:warmup']); $process = runValgrindPhpCgiCommand(['-T1,1', $dir . '/public/index.php']); @@ -64,7 +59,7 @@ function runSymfonyDemo(): array { function runWordpress(): array { $dir = __DIR__ . '/repos/wordpress-6.2'; - cloneRepo($dir, 'git@github.com:iluuu1994/wordpress-6.2.git'); + cloneRepo($dir, 'https://github.com/iluuu1994/wordpress-6.2.git'); /* FIXME: It might be better to use a stable version of PHP for this command because we can't * easily alter the phar file */ From 375190a1fec76d540cd837851194905241057487 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 13 Apr 2023 21:48:57 +0200 Subject: [PATCH 03/11] Adjust benchmark keys --- benchmark/benchmark.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index e7b0d7718e1cc..04fb2066ef30d 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -13,9 +13,9 @@ function main() { global $storeResult; $data = []; - $data['bench.php'] = runBench(); - $data['symfony_demo'] = runSymfonyDemo(); - $data['wordpress_6.2'] = runWordpress(); + $data['Zend/bench.php'] = runBench(); + $data['Symfony Demo 2.2.3'] = runSymfonyDemo(); + $data['Wordpress 6.2'] = runWordpress(); $result = json_encode($data, JSON_PRETTY_PRINT) . "\n"; fwrite(STDOUT, $result); From 74dee73b192600d9ae5a8913534deb25a4b64845 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 13 Apr 2023 22:42:36 +0200 Subject: [PATCH 04/11] Add JIT benchmarks --- benchmark/benchmark.php | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index 04fb2066ef30d..6cfc7e5a101ad 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -13,9 +13,12 @@ function main() { global $storeResult; $data = []; - $data['Zend/bench.php'] = runBench(); - $data['Symfony Demo 2.2.3'] = runSymfonyDemo(); - $data['Wordpress 6.2'] = runWordpress(); + $data['Zend/bench.php'] = runBench(false); + $data['Zend/bench.php JIT'] = runBench(true); + $data['Symfony Demo 2.2.3'] = runSymfonyDemo(false); + $data['Symfony Demo 2.2.3 JIT'] = runSymfonyDemo(true); + $data['Wordpress 6.2'] = runWordpress(false); + $data['Wordpress 6.2 JIT'] = runWordpress(true); $result = json_encode($data, JSON_PRETTY_PRINT) . "\n"; fwrite(STDOUT, $result); @@ -43,21 +46,19 @@ function getPhpSrcCommitHash(): string { return $result->stdout; } -function runBench(): array { - $process = runValgrindPhpCgiCommand([dirname(__DIR__) . '/Zend/bench.php']); - return ['instructions' => extractInstructionsFromValgrindOutput($process->stderr)]; +function runBench(bool $jit): array { + return runValgrindPhpCgiCommand([dirname(__DIR__) . '/Zend/bench.php'], jit: $jit); } -function runSymfonyDemo(): array { +function runSymfonyDemo(bool $jit): array { $dir = __DIR__ . '/repos/symfony-demo-2.2.3'; cloneRepo($dir, 'https://github.com/iluuu1994/symfony-demo-2.2.3.git'); runPhpCommand([$dir . '/bin/console', 'cache:clear']); runPhpCommand([$dir . '/bin/console', 'cache:warmup']); - $process = runValgrindPhpCgiCommand(['-T1,1', $dir . '/public/index.php']); - return ['instructions' => extractInstructionsFromValgrindOutput($process->stderr)]; + return runValgrindPhpCgiCommand([$dir . '/public/index.php'], cwd: $dir, jit: $jit, warmup: 10); } -function runWordpress(): array { +function runWordpress(bool $jit): array { $dir = __DIR__ . '/repos/wordpress-6.2'; cloneRepo($dir, 'https://github.com/iluuu1994/wordpress-6.2.git'); @@ -77,26 +78,35 @@ function runWordpress(): array { // Warmup runPhpCommand([$dir . '/index.php'], $dir); - $process = runValgrindPhpCgiCommand(['-T1,1', $dir . '/index.php'], $dir); - return ['instructions' => extractInstructionsFromValgrindOutput($process->stderr)]; + return runValgrindPhpCgiCommand([$dir . '/index.php'], cwd: $dir, jit: $jit, warmup: 10); } function runPhpCommand(array $args, ?string $cwd = null): ProcessResult { return runCommand([PHP_BINARY, ...$args], $cwd); } -function runValgrindPhpCgiCommand(array $args, ?string $cwd = null): ProcessResult { +function runValgrindPhpCgiCommand( + array $args, + ?string $cwd = null, + bool $jit = false, + int $warmup = 0, +): array { global $phpCgi; - return runCommand([ + $process = runCommand([ 'valgrind', '--tool=callgrind', '--dump-instr=yes', '--callgrind-out-file=/dev/null', '--', $phpCgi, + '-T' . ($warmup ? $warmup . ',' : '') . '1', '-d max_execution_time=0', + '-d opcache.enable=1', + '-d opcache.jit_buffer_size=' . ($jit ? '128M' : '0'), ...$args, ]); + $instructions = extractInstructionsFromValgrindOutput($process->stderr); + return ['instructions' => $instructions]; } function extractInstructionsFromValgrindOutput(string $output): ?string { From b0e0a86394e03e994eb62dcd68f41d14834ddcc2 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Thu, 13 Apr 2023 23:00:24 +0200 Subject: [PATCH 05/11] Use git commit hashes for merge-base --- .github/workflows/push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index ba24465fe6efd..3a26083596319 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -299,5 +299,5 @@ jobs: run: >- php benchmark/generate_diff.php ${{ github.event.pull_request.head.sha }} - $(git merge-base ${{ github.base_ref }} ${{ github.head_ref }}) + $(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }}) > $GITHUB_STEP_SUMMARY From 7da2d6af87857404875490aef1def9611e536d50 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 14 Apr 2023 00:20:47 +0200 Subject: [PATCH 06/11] Remove (possibly?) unused apt packages --- .github/workflows/push.yml | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3a26083596319..0bd52c9b7e33c 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -235,13 +235,10 @@ jobs: sudo apt-get update sudo apt-get install \ bison \ - re2c \ - locales \ - openssl \ - language-pack-de \ - libsqlite3-dev \ libonig-dev \ - libc-client-dev \ + libsqlite3-dev \ + openssl \ + re2c \ valgrind - name: ccache uses: hendrikmuhs/ccache-action@v1.2 @@ -254,17 +251,17 @@ jobs: ./buildconf --force ./configure \ --disable-debug \ - --with-valgrind \ + --enable-mbstring \ --enable-opcache \ --enable-option-checking=fatal \ + --enable-sockets \ + --enable-werror \ --prefix=/usr \ --with-config-file-scan-dir=/etc/php.d \ --with-mysqli=mysqlnd \ - --with-pdo-sqlite \ - --enable-mbstring \ - --enable-sockets \ --with-openssl \ - --enable-werror + --with-pdo-sqlite \ + --with-valgrind - name: make run: make -j$(/usr/bin/nproc) >/dev/null - name: make install From ed93016c28285f287e0e6e62051158e62b772c30 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 14 Apr 2023 12:10:43 +0200 Subject: [PATCH 07/11] Renames --- .github/workflows/push.yml | 4 ++-- benchmark/benchmark.php | 6 +++--- benchmark/generate_diff.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 0bd52c9b7e33c..4503bf7656894 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -226,8 +226,8 @@ jobs: - name: git checkout benchmarking-data uses: actions/checkout@v3 with: - repository: iluuu1994/php-benchmark-data - ssh-key: ${{ secrets.BENCHMARK_DATA_DEPLOY_KEY }} + repository: php/benchmarking-data + ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} path: benchmark/repos/data - name: apt run: | diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index 6cfc7e5a101ad..6b775b9b45ea2 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -30,7 +30,7 @@ function main() { function storeResult(string $result) { $repo = __DIR__ . '/repos/data'; - cloneRepo($repo, 'git@github.com:iluuu1994/php-benchmark-data.git'); + cloneRepo($repo, 'git@github.com:php/benchmarking-data.git'); $commitHash = getPhpSrcCommitHash(); $dir = $repo . '/' . substr($commitHash, 0, 2) . '/' . $commitHash; @@ -52,7 +52,7 @@ function runBench(bool $jit): array { function runSymfonyDemo(bool $jit): array { $dir = __DIR__ . '/repos/symfony-demo-2.2.3'; - cloneRepo($dir, 'https://github.com/iluuu1994/symfony-demo-2.2.3.git'); + 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: 10); @@ -60,7 +60,7 @@ function runSymfonyDemo(bool $jit): array { function runWordpress(bool $jit): array { $dir = __DIR__ . '/repos/wordpress-6.2'; - cloneRepo($dir, 'https://github.com/iluuu1994/wordpress-6.2.git'); + cloneRepo($dir, 'https://github.com/php/benchmarking-wordpress-6.2.git'); /* FIXME: It might be better to use a stable version of PHP for this command because we can't * easily alter the phar file */ diff --git a/benchmark/generate_diff.php b/benchmark/generate_diff.php index 2bfd50e05d3db..8ad8fcc40ef84 100644 --- a/benchmark/generate_diff.php +++ b/benchmark/generate_diff.php @@ -9,7 +9,7 @@ function main(?string $headCommitHash, ?string $baseCommitHash) { } $repo = __DIR__ . '/repos/data'; - cloneRepo($repo, 'git@github.com:iluuu1994/php-benchmark-data.git'); + cloneRepo($repo, 'git@github.com:php/benchmarking-data.git'); $headSummaryFile = $repo . '/' . substr($headCommitHash, 0, 2) . '/' . $headCommitHash . '/summary.json'; $baseSummaryFile = $repo . '/' . substr($baseCommitHash, 0, 2) . '/' . $baseCommitHash . '/summary.json'; if (!file_exists($headSummaryFile)) { From ffcf6ec98367f163c75a8f5ba8f97cbd9f5e4c39 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 14 Apr 2023 13:34:20 +0200 Subject: [PATCH 08/11] Pull before commiting benchmarking files --- .github/workflows/push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4503bf7656894..40a949dde8e68 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -285,6 +285,7 @@ jobs: run: | set -x cd benchmark/repos/data + git pull --autostash git add . if git diff --cached --quiet; then exit 0 From 761ec91601dbabc15ada75d9dfe50056a12a6c8b Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 14 Apr 2023 13:34:49 +0200 Subject: [PATCH 09/11] Increase warmup The JIT takes more warmup to compile all hot traces. --- benchmark/benchmark.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index 6b775b9b45ea2..00a71fa84a967 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -55,7 +55,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: 10); + return runValgrindPhpCgiCommand([$dir . '/public/index.php'], cwd: $dir, jit: $jit, warmup: 50); } function runWordpress(bool $jit): array { @@ -78,7 +78,7 @@ function runWordpress(bool $jit): array { // Warmup runPhpCommand([$dir . '/index.php'], $dir); - return runValgrindPhpCgiCommand([$dir . '/index.php'], cwd: $dir, jit: $jit, warmup: 10); + return runValgrindPhpCgiCommand([$dir . '/index.php'], cwd: $dir, jit: $jit, warmup: 50); } function runPhpCommand(array $args, ?string $cwd = null): ProcessResult { From 64659864fce54b49dfb86d22c5b699b06caa9cb1 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 14 Apr 2023 13:39:53 +0200 Subject: [PATCH 10/11] Fix oci warning --- .github/workflows/push.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 40a949dde8e68..64b21f4126c50 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -265,7 +265,15 @@ jobs: - name: make run: make -j$(/usr/bin/nproc) >/dev/null - name: make install - uses: ./.github/actions/install-linux + run: | + set -x + sudo make install + sudo mkdir -p /etc/php.d + sudo chmod 777 /etc/php.d + echo mysqli.default_socket=/var/run/mysqld/mysqld.sock > /etc/php.d/mysqli.ini + echo zend_extension=opcache.so >> /etc/php.d/opcache.ini + echo opcache.enable=1 >> /etc/php.d/opcache.ini + echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini - name: Setup run: | git config --global user.name "Benchmark" @@ -274,10 +282,6 @@ jobs: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" - mkdir -p /etc/php.d - echo zend_extension=opcache.so >> /etc/php.d/opcache.ini - echo opcache.enable=1 >> /etc/php.d/opcache.ini - echo opcache.enable_cli=1 >> /etc/php.d/opcache.ini - name: Benchmark run: php benchmark/benchmark.php true - name: Store result From e8c07d3b5a62267e3067105016471cd8323dd910 Mon Sep 17 00:00:00 2001 From: Ilija Tovilo Date: Fri, 14 Apr 2023 14:04:42 +0200 Subject: [PATCH 11/11] improve git handling Delay cloning of data repo, abort when there are merge conflicts. --- .github/workflows/push.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 64b21f4126c50..69914207cd91d 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -223,12 +223,6 @@ jobs: uses: actions/checkout@v3 with: fetch-depth: 0 - - name: git checkout benchmarking-data - uses: actions/checkout@v3 - with: - repository: php/benchmarking-data - ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} - path: benchmark/repos/data - name: apt run: | set -x @@ -282,6 +276,12 @@ jobs: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS wordpress" mysql -uroot -proot -e "CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'; FLUSH PRIVILEGES;" mysql -uroot -proot -e "GRANT ALL PRIVILEGES ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" + - name: git checkout benchmarking-data + uses: actions/checkout@v3 + with: + repository: php/benchmarking-data + ssh-key: ${{ secrets.BENCHMARKING_DATA_DEPLOY_KEY }} + path: benchmark/repos/data - name: Benchmark run: php benchmark/benchmark.php true - name: Store result @@ -290,6 +290,10 @@ jobs: set -x cd benchmark/repos/data git pull --autostash + if [ -e ".git/MERGE_HEAD" ]; then + echo "Merging, can't proceed" + exit 1 + fi git add . if git diff --cached --quiet; then exit 0