[RFC] OPcache User Cache Implementation#22534
Open
zeriyoshi wants to merge 1 commit into
Open
Conversation
b64f44b to
0dbb737
Compare
0dbb737 to
347b74f
Compare
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.
RFC: WIP
Re-implementation of #22052 (OPcache Static Cache)
Overview
This implementation includes userland cache backend of OPcache.
Adds the
\Opcache\UserCacheclass, which provides a fast, object-based user-land caching system.Caching system does not serialize objects and scalar values; instead, it uses a shared graph representation to provide a cache that can be quickly retrieved across requests.
This method significantly reduces the processing overhead associated with serializing and deserializing objects in extensions such as APCu, enabling high-speed cache operations. However, since creating a shared graph requires a detailed traversal of the object tree structure, write workloads are generally slower than with APCu.
Also, care must be taken when handling objects intended for serialization. Objects do not involve serialization or deserialization, so they do not execute magic methods such as
__serializeor__unserialize. As a result, the state of some classes that usespl_object_hashor similar functions may become corrupted. To mitigate this, if a property contains an object hash when it is stored, the process includes writing a new value to that property when it is fetched.Safe-Direct path
Objects defined in the C layer—or objects that inherit from these—cannot generally be cached
However, this is possible for objects that implement the Safe-Direct path. In this implementation, this capability has been implemented for certain classes in
ext-dateandext-spl.This provides a means to safely supplement and restore the memory data held by internal objects.
Performance
Running on OrbStack with Ubuntu 24.04 (arm64) on MacBook Air (M4, 32GB). Test harness is available on https://github.com/colopl/php-opcache_user_cache_benchmark_harness
HTML Report: https://github.com/colopl/php-opcache_user_cache_benchmark_harness/blob/main/BENCH_RESULT.html
View GH Pages: https://colopl.github.io/php-opcache_user_cache_benchmark_harness/
API
Please read RFC (WIP)
Closes: #22052