Skip to content

Upload callgrind profile to GA #12212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions benchmark/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/profiles
/repos
20 changes: 16 additions & 4 deletions benchmark/benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -50,15 +55,15 @@ 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 {
$dir = __DIR__ . '/repos/symfony-demo-2.2.3';
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 {
Expand All @@ -81,26 +86,33 @@ 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 {
return runCommand([PHP_BINARY, ...$args], $cwd);
}

function runValgrindPhpCgiCommand(
string $name,
array $args,
?string $cwd = null,
bool $jit = false,
int $warmup = 0,
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,
Expand Down