Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Performance: cache warmup walks the application tree twice and descends into excluded directories

已关闭
#751 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
72/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
php, symfony

调研方向

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 内容生成。

描述

Enhancement Performance

Problem

  • Two walks: CacheWarmer::warmUp() counts the files with iterator_count($iterator) and then calls $iterator->rewind() (src/Instrument/ClassLoading/CacheWarmer.php:80-84). Rewinding the Finder iterator walks the whole appDir again, calling getRealPath() 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 user excludePaths such as vendor/ or node_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), or exclude() with paths relative to in(). Match the directory against the same prefix regex as getPathFilter(). 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 Enumerator and CacheWarmer tests.
  • 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,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

goaop/framework 的其他 Issue

查看 goaop/framework 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。