From de7e1dc774ec29a216c475aa9c571c4c283f3d1c Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Sun, 25 Oct 2026 13:49:28 +0100 Subject: [PATCH] Let TurboProcessRestarter restart without OPcache A program that loads PHPStan, Rector for example, can now pass $withOpcache false. The restart then does the same work for Turbo, xdebug, pcov, uopz and Tideways, but leaves OPcache dormant. The default does not change. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/e2e-tests.yml | 10 ++++++++ .../restart-without-opcache.php | 22 ++++++++++++++++++ src/Turbo/TurboProcessRestarter.php | 23 ++++++++++++++++++- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 e2e/restart-manager/restart-without-opcache.php diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 596535597ae..bb2ed371407 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -2436,6 +2436,16 @@ jobs: exit 1 fi + # another program that loads PHPStan restarts through + # TurboProcessRestarter, and can leave OPcache dormant: the same + # single restart disarms pcov, and no process turns OPcache on + - operating-system: "ubuntu-latest" + coverage: "pcov" + extensions: "" + script: | + php restart-without-opcache.php analyse --no-progress + php check.php restarted-for=pcov pcov-armed=no opcache-cli-on=no processes=2+ starts=2 + # --debug restarts like any other run - it only makes the analysis # serial, --xdebug is what keeps xdebug - operating-system: "ubuntu-latest" diff --git a/e2e/restart-manager/restart-without-opcache.php b/e2e/restart-manager/restart-without-opcache.php new file mode 100644 index 00000000000..6e1368fa625 --- /dev/null +++ b/e2e/restart-manager/restart-without-opcache.php @@ -0,0 +1,22 @@ +_ALLOW_XDEBUG is set - the variable composer/xdebug-handler * reads for that application, so a caller can drop its own xdebug restart. * + * With $withOpcache false, the restart does not turn on OPcache. A run + * that mostly reads the result cache is then faster, and a full analysis + * uses a little more CPU. + * * @api * @param list $argv */ - public static function restartIfSuitable(array $argv, ?string $pharPath = null, ?string $appName = null): void + public static function restartIfSuitable(array $argv, ?string $pharPath = null, ?string $appName = null, bool $withOpcache = true): void { + if (!$withOpcache) { + $extensions = $appName === null + ? [ + 'phpstan_turbo', + 'tideways', + ] + : [ + 'xdebug', + 'pcov', + 'uopz', + 'phpstan_turbo', + 'tideways', + ]; + RestartManager::run($argv, $pharPath, $extensions, $appName ?? 'phpstan'); + return; + } + if ($appName === null) { RestartManager::run($argv, $pharPath, ['phpstan_turbo', 'tideways', 'opcache']); return;