Performance: faster AopComposerLoader::findFile() for classes outside the cache (~1.6 µs per class)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- performance
Research direction
Start in AopComposerLoader::findFile(), named in the issue, and follow it into Enumerator::getFilter() where the include/exclude closures and preg_match run. The proposed change is to pass the already resolved path, replace the SplFileInfo and realpath work with str_starts_with/str_ends_with checks, and compile the path filters into one regex when the enumerator is created. Done means the loader avoids the extra path resolution and per-path closure, with a before/after benchmark showing the ~1.6 µs per class reduction and no behavior change.
Written by the indexing model from the issue text.
Description
Problem
Every class the woven-class cache doesn't know (vendor and framework classes) goes through AopComposerLoader::findFile(), which:
- resolves the path with realpath,
- creates a
SplFileInfothat resolves the path a second time withgetRealPath(), - runs one closure and one
preg_matchper include/exclude path insidearray_any(Enumerator::getFilter).
Measurement
Warm opcache:
| per class | |
|---|---|
| plain composer | 1.2–2.0 µs |
with AopComposerLoader |
2.8–5.3 µs |
| prototype fix (wrapper part only) | 1.98 → 0.33 µs |
Loading the ~21 framework classes a request needs takes 106 µs instead of 58 µs. An app loading 300 vendor classes per request pays about 0.7 ms extra.
Proposal
- Pass the already resolved path along instead of building a
SplFileInfo. - Check the
.phpextension and the app-dir prefix with string functions (str_starts_with,str_ends_with). - Compile the include and exclude paths into one regex each, once, when the enumerator is created.
Estimate
About −1.6 µs per class not in the cache, around −0.5 ms per request for a typical framework-based app. Low risk, small change.
- Dominant language
- PHP
- Stars
- 1.7k
- Forks
- 166
- Avg merge
- 9h 50m
- Merged PRs (30d)
- 30
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
-
Performance: avoid array_slice(…, func_num_args()) in generated methods when all arguments are passedPossibly taken @lisachenko claimed this 1 day ago. OpenEnhancement Performance
Difficulty 3/5 1-2 days Newbie friendliness 55/100
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
-
Feature
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
-
Bug Known Issue
Difficulty 4/5 3-5 days Newbie friendliness 30/100
goaop/framework#696 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 5/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
🧠 Admin
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
pluginsGLPI/tag#389 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 Under an hour Newbie friendliness 78/100
opencart/opencart#15763 · 2 comments · 1 reaction ·
Maintainers usually reply within 1 day
-
support
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
opnsense/core#10976 · 4 comments ·
Maintainers usually reply within 1 day