Performance: INTERCEPT_INCLUDES serves untransformed included files through php://filter in production (no opcache)
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 56/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- backend, performance
Research direction
Start with src/Instrument/Transformer/FilterInjectorTransformer.php, especially rewrite(), and trace how it uses CachePathManager and the include map. Read the related class-cache implementation from #731/#732 and run composer test:performance:transformation to establish a baseline. Add the requested production file-map behavior, then verify intercepted includes of untransformed and woven files in production with and without PREBUILT_CACHE; confirm the performance test still passes.
Written by the indexing model from the issue text.
Description
Problem
With Features::INTERCEPT_INCLUDES, every include/require inside woven code is wrapped in FilterInjectorTransformer::rewrite() (src/Instrument/Transformer/FilterInjectorTransformer.php:118-141). In production, for a file with no woven copy, which is the common case (templates, config files, plain PHP files), the call goes like this:
getCachePathForResource()(:133) callsCachePathManager::queryCacheState(), which loads the full_transformation.cachemetadata file (CachePathManager::loadCacheState(),:177). The include map, which is cheap, carries classes only.getCachePathForResource()returns the rebased path where a woven copy would live, sofile_exists($cachedResource)(:136) is a stat call that returns false.rewrite()falls back tophp://filter/.... The file is then read by the stream filter and checked for freshness (filemtime,filesize,isFreshSince()), and it is compiled on every request: opcache never cachesphp://filterincludes.
Classes have used the include map since #731/#732: known untransformed classes are served natively. Includes never got that path.
Measurement
Same mechanism as the debug-mode issue: a 154-line file costs 0.9 µs through a plain include with warm opcache, and 180 µs through a php://filter pass-through (PHP 8.5, JIT off).
Proposal
-
Add a file map for included resources to
_include.cache: original path relative to the app root mapped tocacheUri|null. Keep the constant-array format and bumpCachePathManager::FORMAT_VERSION. -
In
rewrite()in production:- recorded as untransformed → return the original resolved path;
- recorded as woven → return the recorded
cacheUri, with nofile_exists; - not recorded →
php://filter, as today.
This gives the same semantics as
AopComposerLoader::findFile()for known classes: no freshness check in production. -
Neither path needs
_transformation.cacheany more. -
Debug mode is unchanged by this issue; it is covered by the debug-mode issue.
Acceptance
- Functional coverage for an intercepted include of an untransformed file and of a woven file, in production and with
PREBUILT_CACHE. composer test:performance:transformationbefore and after:FilterInjectorTransformeris touched.
Estimate
About −180 µs per include of an untransformed file per request, plus no more loading of the full metadata file. Low to medium risk, small to medium change.
- Dominant language
- PHP
- Stars
- 1.7k
- Forks
- 166
- Avg merge
- 10h
- Merged PRs (30d)
- 35
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from goaop/framework
-
Intercepting a method imported from a trait with #[\Override] fails: OriginalAlias "has #[\Override] attribute, but no matching parent method exists"Possibly taken @lisachenko claimed this today. OpenBug PHP8.4
Difficulty 3/5 Half a day Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Several woven classes in one file: their proxies overwrite each other, all but the last class are lost (Class not found)Possibly taken @lisachenko claimed this today. OpenBug
Difficulty 4/5 3-5 days Newbie friendliness 38/100
Maintainers usually reply within 1 day
-
Proxy of a namespaced class extending a global class references the parent unqualified (Class "Ns\ArrayObject" not found)Possibly taken @lisachenko claimed this today. OpenBug
Difficulty 3/5 1-2 days Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Enhancement Performance
Difficulty 5/5 Over a week Newbie friendliness 35/100
goaop/framework#747 · 1 comment ·
Maintainers usually reply within 1 day
-
Enhancement Performance To Be Discussed
Difficulty 3/5 Half a day Newbie friendliness 55/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
codeigniter4/CodeIgniter4#10616 ·
Maintainers usually reply within 1 day
-
bug code quality
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SemanticMediaWiki/SemanticMediaWiki#7149 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
google/site-kit-wp#13825 ·
Maintainers usually reply within 3 days
-
Made by AI module: MCP type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day