Skip to content

Let TurboProcessRestarter restart without OPcache - #6837

Closed
SanderMuller wants to merge 1 commit into
phpstan:2.3.xfrom
SanderMuller:turbo-restart-without-opcache
Closed

SanderMuller wants to merge 1 commit into
phpstan:2.3.xfrom
SanderMuller:turbo-restart-without-opcache

Conversation

@SanderMuller

Copy link
Copy Markdown
Contributor

This adds an optional $withOpcache parameter to TurboProcessRestarter::restartIfSuitable(). With false, the restart still loads Turbo and disarms xdebug, pcov and uopz, but it does not turn on OPcache. The default does not change.

This is for Rector, where a warm run is slower with OPcache on. In a warm run, the main process compiles each file it loads once and then exits. Forked workers turn OPcache off, so only the main process uses it.

PHPStan keeps OPcache, because it helps a cold run. I measured PHPStan 2.3.2 (with #6834) on GitHub runners, on 1252 files of Rector's own code at level 5. The only change between the two arms is the opcache restart reason. A cold run has no result cache, and a run without tmpDir also builds the container. Medians:

OPcache on OPcache off
warm, x86 1.40 s 1.03 s
warm, arm64 1.26 s 0.99 s
cold, x86 (wall / CPU) 10.62 / 36.7 s 10.70 / 38.0 s
cold, arm64 8.87 / 29.9 s 9.12 / 31.7 s
no tmpDir, x86 12.34 / 41.0 s 12.80 / 43.9 s
no tmpDir, arm64 10.14 / 32.8 s 10.42 / 34.5 s

#6634 tries to keep the cold gain without the warm cost. I have not measured it on cold runs yet.

Both arms report the same errors. The new e2e row runs PHPStan through a wrapper that restarts with $withOpcache false. It checks that one restart disarms pcov and that OPcache stays off. I ran the same check locally with xdebug as the restart reason. Without the change, it fails on restarted-for and opcache-cli-on.

🤖 Generated with Claude Code

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) <[email protected]>
@ondrejmirtes

Copy link
Copy Markdown
Member

I feel like we don't need to give this option. Cold runs are faster with OPCache, and we might be able to make warm runs faster later with a daemon process.

It's not like we have the data about whether the run will be warm or cold at that point to decide "do we want OPCache or not?".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants