Problem
src/Core.php:1180-1193 (preloadFrameworkClasses()) recursively walks src/ with a RecursiveDirectoryIterator and include_onces every .php file (~180 files, plus the stat cost of the walk) on each Core::init() — including the ~55 ClassExtension hook interfaces a given consumer will never touch. It also runs again on a re-init() after shutdown().
The stated purpose (the "bypass all possible hooks" comment) is to ensure classes reachable from FFI hook trampolines are loaded without triggering autoloading mid-callback — a real constraint, but one that doesn't require the whole library.
Options
- Minimum: guard with the
self::$initialized / a static $preloaded flag so re-init doesn't repeat the walk.
- Better: replace the directory walk with an explicit list (generated or hand-maintained + CI-checked) of the classes actually reachable from hook trampolines, and preload only those.
- Alternative: document
opcache.preload (preload.php already exists) as the supported mechanism for production and reduce the runtime fallback to option 2's minimal set.
Numbers and call path verified during the 2026-08 modernization review.
Problem
src/Core.php:1180-1193(preloadFrameworkClasses()) recursively walkssrc/with aRecursiveDirectoryIteratorandinclude_onces every.phpfile (~180 files, plus the stat cost of the walk) on eachCore::init()— including the ~55ClassExtensionhook interfaces a given consumer will never touch. It also runs again on a re-init()aftershutdown().The stated purpose (the "bypass all possible hooks" comment) is to ensure classes reachable from FFI hook trampolines are loaded without triggering autoloading mid-callback — a real constraint, but one that doesn't require the whole library.
Options
self::$initialized/ astatic $preloadedflag so re-init doesn't repeat the walk.opcache.preload(preload.phpalready exists) as the supported mechanism for production and reduce the runtime fallback to option 2's minimal set.Numbers and call path verified during the 2026-08 modernization review.