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..e65e3c8210794 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; +}