Performance: cache warmup walks the application tree twice and descends into excluded directories
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 72/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 领域
- backend, performance
调研方向
Start with src/Instrument/ClassLoading/CacheWarmer.php and src/Instrument/FileSystem/Enumerator.php, then read the related Enumerator and CacheWarmer tests. Check how the Finder iterator is counted, rewound, and filtered, including wildcard exclusions, before changing the traversal. Done means the same files are processed, excluded directories are pruned safely, the tests cover both classes, and timing is compared on a tree with a large excluded directory.
由索引模型根据 Issue 内容生成。
描述
Problem
- Two walks:
CacheWarmer::warmUp()counts the files withiterator_count($iterator)and then calls$iterator->rewind()(src/Instrument/ClassLoading/CacheWarmer.php:80-84). Rewinding the Finder iterator walks the wholeappDiragain, callinggetRealPath()and the path filter for every file. - No pruning:
Enumerator::enumerate()(src/Instrument/FileSystem/Enumerator.php:54-61) applies the include/exclude filter per file only. Finder still descends into every excluded directory: the cache directory, the framework's runtime dependencies, and userexcludePathssuch asvendor/ornode_modules/.
Measurement
appDir = vendor/ (3,942 PHP files): count pass 53 ms, second pass 44 ms. The cost grows with the size of excluded trees, which can be much larger than the woven code, for example a full vendor/ plus node_modules/ under the app root.
Proposal
- One walk: collect the iterator once (
iterator_to_array(..., false), which also removes the separate Windows rewind workaround), then count and process from that array. - Prune excluded directories: use Finder's
filter(..., prune: true), available since symfony/finder 6.4 (the framework requires^7.4 || ^8.0), orexclude()with paths relative toin(). Match the directory against the same prefix regex asgetPathFilter(). Exclude patterns with*wildcards that could still match files inside a directory must not prune it.
Acceptance
- The warmup processes exactly the same files as before; extend the
EnumeratorandCacheWarmertests. - A timing of the enumeration before and after on a tree with a large excluded directory.
Estimate
Halves the enumeration time, and more when large excluded trees sit under appDir. Low risk, small change.
- 主要语言
- PHP
- 星标
- 1.7k
- 派生
- 166
- 平均合并
- 11 小时 20 分钟
- 30 天内合并 PR
- 37
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
goaop/framework 的其他 Issue
-
Intercepting a method imported from a trait with #[\Override] fails: OriginalAlias "has #[\Override] attribute, but no matching parent method exists"可能已有人在做 @lisachenko 于 6 天前认领。 未关闭Bug PHP8.4
难度 3/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
Several woven classes in one file: their proxies overwrite each other, all but the last class are lost (Class not found)可能已有人在做 @lisachenko 于 6 天前认领。 未关闭Bug
难度 4/5 3-5 天 新手友好度 38/100
维护者通常 1 天内回复
-
Enhancement Performance
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
Enhancement Performance To Be Discussed
难度 3/5 半天 新手友好度 55/100
维护者通常 1 天内回复
-
Feature
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
HttpRequestTrait fatals on WordPress 7.2: $blocked_http_requests clashes with WP_UnitTestCase_Base未关闭
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 1/5 1 小时以内 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 78/100
pluginsGLPI/addressing#127 ·