nextcloud-server/apps/settings/lib/SetupChecks
MichaIng d10a87f85f feat(settings): simplify OPcache checks
For the overall OPcache size check, we currently compare used memory with free memory. However, `opcache.memory_consumption` is split into `used_memory`, `free_memory` and `wasted_memory`. When cached files change on disk, old entries are not replaced or removed, but remain as wasted memory, until the cache is actually full, and if their percentage is above `opcache.max_wasted_percentage`, which is 5% by default. When this happens, the engine is restarted, resetting the cache completely, like a `opcache_reset()` call.

As long as we do not consider wasted cache, recommendations based on free memory can be false. To solve this, we could count wasted memory as free memory, if it is above `opcache.max_wasted_percentage`, as the engine will be restarted as soon as needed, freeing up this wasted space. On the other hand, wasted memory below the threshold permanently blocks the OPcache, which supports counting it as used memory. Depending on the situation, instead of raising OPcache size, it could be also advised to reduce `opcache.max_wasted_percentage`. But too frequent cache resets break its purpose as well.

In my opinion, the matter is too complex to consider wasted cache correctly, and do precise recommendations, but we should focus on reducing false positives instead. What we know for sure is: if the cache is full (`$status['cache_full'] === true`), and the limit for cached keys has not been reached, the OPcache was too small to maintain free space, with wasted memory below the configured threshold, where it consumes memory permanently. Recommending to raise the OPcache size in this case, is hence as accurate as it gets. Even if 5% wasted cache could be freed, 95% used memory is still above the previous threshold for the setup check warning. And if `opcache.max_wasted_percentage` is above 5%, then the admin must have decided to change the default, deciding that system memory consumption has lower priority than preventing OPcache engine restarts.

`cache_full` can be true as well if the limit for cached keys has been reached, hence we need to merge both checks. In this case `num_cached_keys` equals `max_cached_keys` exactly, hence it is easy to differentiale whether `opcache.max_accelerated_files` or `opcache.memory_consumption` needs to be raised to address the `cache_full` state.

In practice, this change relaxes the checks: the respective limit needs to be reached 100% instead of 90%, to trigger a warning, eliminating also false alarms if a large share of the cache is consumed by wasted memory, which would be automatically freed once cache is 100% full.

Additionally, the recommendation for raising `opcache.max_accelerated_files` now says "a value higher than `max_cached_keys`", instead of "higher than `opcache.max_accelerated_files`". The actual limit, reflected by `max_cached_keys` from `opcache_get_status()`, [is a next higher value from a set of prime numbers](https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.max-accelerated-files). E.g. if `opcache.max_accelerated_files` is set to 10,000 (PHP default), the effective limit is 16,229 OPcache keys. Recommending "higher than 10000" could hence lead to a settings change without effect. For an effective change, the new value needs to be "higher than 16229" instead, which is what the setup check will show in this situation, with this change applied.

Signed-off-by: MichaIng <micha@dietpi.com>
2025-07-13 22:51:17 +07:00
..
AllowedAdminRanges.php fix(l10n): Improve english source strings 2025-02-26 13:08:49 +07:00
AppDirsWithDifferentOwner.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
BruteForceThrottler.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
CheckUserCertificates.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
CodeIntegrity.php fix(IntegrityCheck): Ensure the check is run if no results are available 2024-07-03 11:37:49 +07:00
CronErrors.php chore(deps): Update nextcloud/coding-standard to v1.3.1 2024-09-19 14:21:20 +07:00
CronInfo.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
DataDirectoryProtected.php feat: Make `CheckServerResponseTrait` public and provide as `OCP\SetupCheck\CheckServerResponseTrait` 2024-09-16 14:58:21 +07:00
DatabaseHasMissingColumns.php chore(deps): Update nextcloud/coding-standard to v1.3.1 2024-09-19 14:21:20 +07:00
DatabaseHasMissingIndices.php fix(l10n): Improve english source strings 2025-02-26 13:08:49 +07:00
DatabaseHasMissingPrimaryKeys.php chore(deps): Update nextcloud/coding-standard to v1.3.1 2024-09-19 14:21:20 +07:00
DatabasePendingBigIntConversions.php chore(deps): Update nextcloud/coding-standard to v1.3.1 2024-09-19 14:21:20 +07:00
DebugMode.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
DefaultPhoneRegionSet.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
EmailTestSuccessful.php fix(settings): Fix setup check when mail_smptmode is set to "null" 2025-01-30 08:35:14 +07:00
FileLocking.php fix(setupChecks): Having transactional file locking disabled is not supported 2024-09-19 12:50:59 +07:00
ForwardedForHeaders.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
HttpsUrlGeneration.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
InternetConnectivity.php perf(settings): Speed up InternetConnectivity setup check 2025-01-07 16:49:28 +07:00
JavaScriptModules.php feat: Make `CheckServerResponseTrait` public and provide as `OCP\SetupCheck\CheckServerResponseTrait` 2024-09-16 14:58:21 +07:00
JavaScriptSourceMaps.php feat: Make `CheckServerResponseTrait` public and provide as `OCP\SetupCheck\CheckServerResponseTrait` 2024-09-16 14:58:21 +07:00
LegacySSEKeyFormat.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
MaintenanceWindowStart.php style: update codestyle for coding-standard 1.2.3 2024-08-25 19:34:58 +07:00
MemcacheConfigured.php fix(setupchecks): Binary data can have problems with serialize 2025-01-09 23:42:07 +07:00
MimeTypeMigrationAvailable.php fix(settings): use correct scope for translations 2025-07-03 12:23:55 +07:00
MysqlRowFormat.php fix: Change SQL query so that it is ansi safe 2025-02-27 09:01:17 +07:00
MysqlUnicodeSupport.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
OcxProviders.php chore(deps): Update nextcloud/coding-standard to v1.3.1 2024-09-19 14:21:20 +07:00
OverwriteCliUrl.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
PhpApcuConfig.php feat(settings): Add setup check for apcu cache expunge 2024-08-27 10:45:32 +07:00
PhpDefaultCharset.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
PhpDisabledFunctions.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
PhpFreetypeSupport.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
PhpGetEnv.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
PhpMaxFileSize.php fix(settings): psalm PhpMaxFileSize setup check warning 2024-11-19 18:27:35 +07:00
PhpMemoryLimit.php fix(settings): Add some context to the PHP memory limit error 2025-01-26 20:48:16 +07:00
PhpModules.php fix(webauthn): do not require bcmath or gmp - not needed anymore 2025-04-01 19:10:11 +07:00
PhpOpcacheSetup.php feat(settings): simplify OPcache checks 2025-07-13 22:51:17 +07:00
PhpOutdated.php fix(setupcheck): Update setup check for PHP version to be more accurate 2025-02-10 18:47:59 +07:00
PhpOutputBuffering.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
PushService.php style: update codestyle for coding-standard 1.2.3 2024-08-25 19:34:58 +07:00
RandomnessSecure.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
ReadOnlyConfig.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
SchedulingTableSize.php fix(caldav): lower scheduling table size warning 2024-07-17 11:20:49 +07:00
SecurityHeaders.php chore(deps): Update nextcloud/coding-standard to v1.3.1 2024-09-19 14:21:20 +07:00
SupportedDatabase.php feat: Update supported PostgreSQL versions 2024-11-13 02:50:13 +07:00
SystemIs64bit.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
TaskProcessingPickupSpeed.php chore(18n): More natural english - fix plural typo 2025-05-26 10:10:15 +07:00
TempSpaceAvailable.php chore(deps): Update nextcloud/coding-standard to v1.3.1 2024-09-19 14:21:20 +07:00
TransactionIsolation.php chore: Add SPDX header 2024-06-03 20:33:31 +07:00
WellKnownUrls.php fix(SetupChecks): Pass webfinger if a handler is there 2025-01-26 14:37:05 +07:00
Woff2Loading.php feat: Make `CheckServerResponseTrait` public and provide as `OCP\SetupCheck\CheckServerResponseTrait` 2024-09-16 14:58:21 +07:00