From 90770f5b791e244738d67462bf74c1beb8e83ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 6 Apr 2026 23:48:33 +0200 Subject: [PATCH 1/2] Disable ASLR during benchmarking for target process only --- .github/workflows/test-suite.yml | 4 ---- benchmark/benchmark.php | 4 ++++ benchmark/shared.php | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test-suite.yml b/.github/workflows/test-suite.yml index 90bcafd16307e..0614892e9e6c6 100644 --- a/.github/workflows/test-suite.yml +++ b/.github/workflows/test-suite.yml @@ -1012,10 +1012,6 @@ jobs: with: ref: ${{ fromJson(inputs.branch).ref }} fetch-depth: 0 - # ASLR can cause a lot of noise due to missed sse opportunities for memcpy - # and other operations, so we disable it during benchmarking. - - name: Disable ASLR - run: echo 0 | sudo tee /proc/sys/kernel/randomize_va_space - name: apt run: | set -x diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index 0c2ac4c6010a4..1a16bcef87a92 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -109,12 +109,16 @@ function runValgrindPhpCgiCommand( ): array { global $phpCgi; + // ASLR can cause a lot of noise due to missed sse opportunities for memcpy and other operations + $aslrDisable = checkPersonalityAslrDisablePermission(); + $profileOut = __DIR__ . "/profiles/callgrind.out.$name"; if ($jit) { $profileOut .= '.jit'; } $process = runCommand([ + ...($aslrDisable ? ['setarch', '--addr-no-randomize'] : []), 'valgrind', '--tool=callgrind', '--dump-instr=yes', diff --git a/benchmark/shared.php b/benchmark/shared.php index 0f58a2a1bf870..ecfaee455b1ea 100644 --- a/benchmark/shared.php +++ b/benchmark/shared.php @@ -72,3 +72,16 @@ function cloneRepo(string $path, string $url) { } runCommand(['git', 'clone', '-q', '--end-of-options', $url, $repo], dirname($path)); } + +function checkPersonalityAslrDisablePermission(): bool { + $processResult = runCommand(['sh', '-c', 'setarch --addr-no-randomize sh -c \'cat /proc/self/personality\' || true'], null, false); + + $n = hexdec($processResult->stdout); + if (($n & 0x4_00_00) === 0) { + fwrite(STDOUT, 'Unable to disable ASLR: ' . trim($processResult->stderr) . "\n"); + + return false; + } + + return true; +} From b663df5187355f778efcbbeb93d03bb1a01290e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Vo=C5=99=C3=AD=C5=A1ek?= Date: Mon, 6 Apr 2026 23:55:03 +0200 Subject: [PATCH 2/2] improve comment case --- benchmark/benchmark.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/benchmark/benchmark.php b/benchmark/benchmark.php index 1a16bcef87a92..e65e3c8210794 100644 --- a/benchmark/benchmark.php +++ b/benchmark/benchmark.php @@ -109,7 +109,7 @@ function runValgrindPhpCgiCommand( ): array { global $phpCgi; - // ASLR can cause a lot of noise due to missed sse opportunities for memcpy and other operations + // ASLR can cause a lot of noise due to missed SSE opportunities for memcpy and other operations $aslrDisable = checkPersonalityAslrDisablePermission(); $profileOut = __DIR__ . "/profiles/callgrind.out.$name";