-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
fix(setupchecks): Skip checking for OPcache settings if running checks from CLI #46353
Conversation
Signed-off-by: Git'Fellow <[email protected]>
/backport to stable29 |
/backport to stable28 |
@@ -114,6 +114,11 @@ protected function getOpcacheSetupRecommendations(): array { | |||
} | |||
|
|||
public function run(): SetupResult { | |||
// Skip OPcache checks if running from CLI | |||
if (PHP_SAPI === 'cli') { | |||
return SetupResult::success($this->l10n->t('Checking from CLI, OPcache checks have been skipped.')); |
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.
return SetupResult::success($this->l10n->t('Checking from CLI, OPcache checks have been skipped.')); | |
return SetupResult::info($this->l10n->t('This check is skipped because OPcache is turned off.')); |
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.
Not sure in how far the output style of info
differs from success
, but I would indeed rate it as success when OPcache is disabled for CLI, since this is recommended for production systems. And in any case, the text should keep the info that it is skipped because we are running from CLI, or "turned off for CLI", else the information can be confusing.
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.
Why is recommended to disable opcache for CLI? This is unexpected to me, the cron and occ commands should also benefit from opcache, no?
|
Signed-off-by: Git'Fellow <[email protected]>
Signed-off-by: Git'Fellow <[email protected]>
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.
Looks good:
php:
✓ PHP default charset: UTF-8
✓ PHP set_time_limit: The function is available.
✓ Freetype: Supported
✓ PHP getenv
✓ PHP memory limit: 512 MB
ℹ PHP modules: This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them:
- bcmath for WebAuthn passwordless login
- gmp for WebAuthn passwordless login, and SFTP storage
✓ PHP opcache: Checking from CLI, OPcache checks have been skipped.
✓ PHP "output_buffering" option: Disabled
ℹ PHP Imagick module: The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.
After setting opcache.enable_cli=1
:
php:
✓ PHP default charset: UTF-8
✓ PHP set_time_limit: The function is available.
✓ Freetype: Supported
✓ PHP getenv
✓ PHP memory limit: 512 MB
ℹ PHP modules: This instance is missing some recommended PHP modules. For improved performance and better compatibility it is highly recommended to install them:
- bcmath for WebAuthn passwordless login
- gmp for WebAuthn passwordless login, and SFTP storage
✓ PHP opcache: Correctly configured
✓ PHP "output_buffering" option: Disabled
ℹ PHP Imagick module: The PHP module "imagick" is not enabled although the theming app is. For favicon generation to work correctly, you need to install and enable this module.
Not sure whether we can easily add correct indentation after line breaks?
In addition, with opcache.log_verbosity_level=3
, I see a few pages with lines like:
Mon Jul 8 16:01:59 2024 (21777): Message Cached script '/var/www/nextcloud/lib/public/AppFramework/Http/Attribute/UseSession.php'
Mon Jul 8 16:01:59 2024 (21777): Message Added key '/var/www/nextcloud/lib/composer/composer/../../../lib/public/AppFramework/Http/Attribute/UseSession.php'
indicating how the OPcache is filled. On a Raspberry Pi 2, this increases the time of all occ
calls by 1.5 - 2 seconds:
root@micha:/var/www/nextcloud# time ncc setupchecks &> /dev/null
real 0m17.633s
user 0m0.010s
sys 0m0.059s
root@micha:/var/www/nextcloud# time ncc setupchecks &> /dev/null
real 0m17.664s
user 0m0.041s
sys 0m0.030s
root@micha:/var/www/nextcloud# sed -i '/^opcache.enable_cli=/s/^/#/' /etc/php/8.2/mods-available/micha.ini # disable OPcache
root@micha:/var/www/nextcloud# time ncc setupchecks &> /dev/null
real 0m15.744s
user 0m0.025s
sys 0m0.047s
root@micha:/var/www/nextcloud# time ncc setupchecks &> /dev/null
real 0m15.813s
user 0m0.027s
sys 0m0.043s
root@micha:/var/www/nextcloud# time ncc &> /dev/null
real 0m2.557s
user 0m0.031s
sys 0m0.040s
root@micha:/var/www/nextcloud# time ncc &> /dev/null
real 0m2.562s
user 0m0.032s
sys 0m0.039s
root@micha:/var/www/nextcloud# sed -i '/^#opcache.enable_cli=/s/#//' /etc/php/8.2/mods-available/micha.ini # enable OPcache
root@micha:/var/www/nextcloud# time ncc &> /dev/null
real 0m4.123s
user 0m0.032s
sys 0m0.039s
root@micha:/var/www/nextcloud# time ncc &> /dev/null
real 0m4.054s
user 0m0.022s
sys 0m0.051s
@come-nc just to demonstrate that it really makes sense to have OPcache disabled for CLI.
Then it should not even say "✓ PHP opcache: Correctly configured" when it is enabled, no? |
But we might want to be able to test checks from CLI? Also, while it is good that we do not print a warning without |
There is the same problem with all checks on PHP configuration, running them from CLI tests the wrong configuration. |
Not necessarily the wrong configuration, only the wrong usage stats for sure. It would still be possible to configure PHP either for all SAPI's or CLI in particular the wrong and right way, and test whether // We cannot check the PHP web SAPI config and OPcache usage stats from CLI
// and building the OPcache usually worsens the performance of CLI calls.
// Hence recommend to disable OPcache for CLI (which is the PHP default) and skip further OPcache checks.
if (\OC::$CLI && !defined('PHPUNIT_RUN')) {
if ($this->iniGetWrapper->getBool('opcache.enable_cli')) {
return SetupResult::warning($this->l10n->t('OPcache is enabled for CLI. For better occ and background job performance, it is recommended to apply "opcache.enable_cli=0" to your PHP configuration.'));
}
return SetupResult::success($this->l10n->t('OPcache is disabled for CLI as recommended. Skipping further OPcache checks.'));
} However, while |
We should not have checks for |
Hello there, We hope that the review process is going smooth and is helpful for you. We want to ensure your pull request is reviewed to your satisfaction. If you have a moment, our community management team would very much appreciate your feedback on your experience with this PR review process. Your feedback is valuable to us as we continuously strive to improve our community developer experience. Please take a moment to complete our short survey by clicking on the following link: https://cloud.nextcloud.com/apps/forms/s/i9Ago4EQRZ7TWxjfmeEpPkf6 Thank you for contributing to Nextcloud and we hope to hear from you soon! (If you believe you should not receive this message, you can add yourself to the blocklist.) |
@come-nc are we good to go here as-is for now? |
occ setupchecks
- OPcache Configuration Checks should not be performed ifopcache.enable_cli
is disabled #46351Summary
We don't recommend to enable OPcache on CLI, so disable the checks in this case.
Checklist