fix: throttle opcache_reset()-triggered thread pool reboots - #2570
Open
dunglas wants to merge 1 commit into
Open
fix: throttle opcache_reset()-triggered thread pool reboots#2570dunglas wants to merge 1 commit into
dunglas wants to merge 1 commit into
Conversation
opcache_reset() was rebooting the whole PHP thread pool on every single call, unthrottled. Some applications (e.g. WordPress plugins) call opcache_reset() on nearly every request; each reboot pauses request handling for the whole pool, which compounds into sustained, severe slowdowns and dropped connections under real traffic. Coalesce calls into at most one reboot per 5s cooldown instead. Fixes #2553.
Contributor
|
I don't think this would help as at least one of the cases I was able to reproduce this with was a client stall during go_post_read |
dunglas
marked this pull request as ready for review
July 28, 2026 15:26
Contributor
|
Also not sure this would help, #2553 says rebooting periodically fixes the issue and opcache_reset basically does the same thing as a reboot currently |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
go_schedule_opcache_reset()spawned a full PHP thread pool reboot on every singleopcache_reset()call, with no rate limiting. A reboot pauses request handling across the whole pool (drains every thread, force-kills stragglers after a grace period, recreates the main thread).Some applications call
opcache_reset()on nearly every request — the reporter of #2553 found several WordPress plugins doing exactly this across 19 sites on one host. Each call triggers its own reboot, and the reboots compound into sustained, severe slowdowns (write error,stream closed,client disconnectedin the logs) rather than a single blip.Fix
Coalesce
opcache_reset()-triggered reboots into at most one per 5s cooldown window. The first call in a burst still reboots immediately; calls arriving within the cooldown are skipped rather than each pausing the pool again. This only throttles the automaticopcache_reset()hook —RestartWorkers()(used by the watcher/hot-reload and any explicit caller) is untouched and always takes effect immediately.Tests
TestOpcacheResetIsThrottled: 10 sequentialopcache_reset()calls 50ms apart (well within the cooldown, but each landing after the previous reboot would have already finished) — fails with 10 reboots on the unpatched code, passes with 1 reboot with the fix.TestOpcacheResetstress test (500 concurrent requests spammingopcache_reset()under load) still passes.Fixes #2553.