Skip to content

RFC: opcache-friendly advisor cache instead of serialize()/unserialize() #636

Description

@lisachenko

Problem

The advisor cache is the last serialize()-based store in the framework (src/Core/CachedAspectLoader.php:113-141: serialize() at ~:118, @unserialize() at ~:136), while CachePathManager::writeCacheFile() already emits <?php return …; files that opcache keeps compiled. Costs today:

  1. Every request re-parses a serialized blob that opcache cannot cache.
  2. @unserialize() silently swallows corruption.
  3. Object-graph revival forces the __sleep/__wakeup/__serialize machinery, which reaches back into the AspectKernel singleton (src/Aop/Framework/AbstractInterceptor.php:145, src/Aop/Pointcut/PointcutReference.php:54-62).

Proposed design (for discussion)

  • Emit advisor definitions as a compiled PHP file: either var_exported construction code or a compact array descriptor + factory that rebuilds pointcuts/advisors.
  • Include a cache-format version marker so stale cache dirs re-warm automatically.
  • Fold in migrating PointcutReference from __sleep/__wakeup to __serialize/__unserialize (the only legacy pair left in src/), which also unblocks making it readonly.

Effort L, risk medium (cache format change). Needs design discussion before implementation — notably how closures/first-class-callable advices are represented in exported form, and interplay with #618.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions