[php-src] PR #22534: [RFC] OPcache User Cache Implementation

From: Date: Wed, 01 Jul 2026 12:56:05 +0000
Subject: [php-src] PR #22534: [RFC] OPcache User Cache Implementation
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-36758@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/22534 Author: zeriyoshi Re-implementation of #22052 (OPcache _Static_ Cache) ## Overview This implementation includes userland cache backend of OPcache. Adds the \Opcache\UserCache class, 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 __serialize or __unserialize. As a result, the state of some classes that use spl_object_hash or 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-date and ext-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 ### API Please read RFC (WIP) Closes: #22052

« previous php.git-pulls (#36758) next »