This PR introduces a new built-in extension, ext-user_cache, to PHP.
It replaces the earlier OPcache Static Cache (#22534) and OPcache User Cache (#22052) proposals.
It is a refined version whose design has been completely rethought and reimplemented from scratch, rather than carried over from the previous proposals.
The previous discussion of the OPcache Static Cache can be found on the internals mailing list (externals.io): https://externals.io/message/130912
ext-user_cache provides high-performance caching that persists across request boundaries.
Values are stored in and retrieved from pre-allocated shared memory (SHM) through one of the following paths:
Scalar values are copied directly.
Objects that can use a shared graph representation are converted to that representation and copied.
Internal or extension classes that have a safe direct-conversion (safe direct) path (e.g. ext-date, ext-spl) are converted to a shared graph representation and copied.
Values with certain magic methods such as __serialize are serialized with a fast internal serializer and then copied.
Unsupported values result in an error.
The extension is enabled by default and enforces appropriate security boundaries for each SAPI. Even when it is disabled, libraries can continue to use it transparently; they simply gain no caching benefit.
The extension is designed specifically for fetch-heavy workloads, so its write performance is lower than that of existing third-party extensions. However, I believe this trade-off is acceptable given the nature of caching.
Detailed benchmarks and their test suites are available here:
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
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.
RFC: https://wiki.php.net/rfc/impl_user_cache
This PR introduces a new built-in extension, ext-user_cache, to PHP.
It replaces the earlier OPcache Static Cache (#22534) and OPcache User Cache (#22052) proposals.
It is a refined version whose design has been completely rethought and reimplemented from scratch, rather than carried over from the previous proposals.
The previous discussion of the OPcache Static Cache can be found on the internals mailing list (externals.io): https://externals.io/message/130912
ext-user_cache provides high-performance caching that persists across request boundaries.
Values are stored in and retrieved from pre-allocated shared memory (SHM) through one of the following paths:
The extension is enabled by default and enforces appropriate security boundaries for each SAPI. Even when it is disabled, libraries can continue to use it transparently; they simply gain no caching benefit.
The extension is designed specifically for fetch-heavy workloads, so its write performance is lower than that of existing third-party extensions. However, I believe this trade-off is acceptable given the nature of caching.
Detailed benchmarks and their test suites are available here: