-
Notifications
You must be signed in to change notification settings - Fork 7.9k
opcache: fix revalidation in long running CLI scripts #18671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: PHP-8.3
Are you sure you want to change the base?
Conversation
8d75fcd
to
702c189
Compare
702c189
to
e210c08
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically the patch looks OK and the general idea makes sense.
However, the original behavior also makes sense for the most use cases and for the "static" CLI apps the new behaviour would introduce useless gettimeofday syscalls.
Instead of the new behavior for CLI mode only, I would think about consistent landing of this future in general. For example, we may define a new special opcache.revalidate_freq=-1
setting.
Hi @dstogov, Thank you for taking the time to review the patch and for the thoughtful feedback. I may have misread your suggestion to use To achieve that without overloading revalidate_freq, would you be open to adding a dedicated switch, e.g.
Default would remain 0 for all SAPIs, preserving today’s behaviour; setting it to 1 would enable the new moving-window logic while still honouring revalidate_freq. In this case I can remove SAPI check in the patch as this may be controllable through separate php-cli.ini. If this sounds acceptable I’ll update the patch, add the new ini entry to both development and production templates, and ping you for another look. Thanks again for your guidance! |
It looks like opcache was initially designed with short-lived requests in mind, so when checking if the file should be re-validated, the code uses 'request time' instead of 'now', where request time is calculated once on the script startup. Which basically means that in CLI this check will never succeed.
This PR containing the patch to fix this issue covered with a test that passes in this branch but not in PHP-8.3.
The issue itself is older, but I rebased the patch to PHP-8.3 as mentioned in CONTRIBUTING doc.
Not sure if I must fill the issue separately, but will be happy to do if needed.