Performance: do not merge the woven class map into composer's class map (~260 µs with an optimized autoloader)
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- Half a day
- Newbie friendliness
- 55/100
- Issue type
- Refactor
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- php
- Domain
- performance
Research direction
The loader is AopComposerLoader, with the relevant methods __construct and findFile(); start by reading __construct to see the addClassMap($this->classMap) call and how classMap is built. Then read composer's ClassLoader::addClassMap() and findFile() to understand the merge cost and the direct-findFile behaviour the Risk section flags. Make findFile() check $this->classMap[$class] before delegating, and run the autoloader tests to confirm woven and non-woven classes both still resolve. Done means the merge is gone without breaking direct findFile() callers.
Written by the indexing model from the issue text.
Description
Problem
In production, AopComposerLoader::__construct calls $original->addClassMap($this->classMap). Composer's addClassMap() runs array_merge over its whole class map. The cost depends on the size of the app's composer class map, not on how many classes are woven.
Measurement
With a 30k-entry optimized class map (composer dump-autoload -o, common in production), the merge costs about 260 µs and ~1 MB of memory per request (about 8.7 ns per entry).
Proposal
Drop the addClassMap() call. Look up $this->classMap[$class] first in AopComposerLoader::findFile(); this also skips composer's own lookup for woven classes.
Risk (why "To Be Discussed")
Code that calls composer's findFile() directly, for example via ClassLoader::getRegisteredLoaders() (some tools and frameworks do this), would get the original file for woven classes instead of the woven one. We need to decide whether that is acceptable or whether to keep a slower compatible mode as an option.
Estimate
Up to −260 µs per request for large apps with an optimized autoloader. Medium risk, small 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
-
Performance: INTERCEPT_INCLUDES serves untransformed included files through php://filter in production (no opcache)Possibly taken @lisachenko claimed this 2 days ago. OpenEnhancement Performance
Difficulty 4/5 3-5 days Newbie friendliness 56/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Made by AI module: MCP type: bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
hawk-digital-environments/HAWKI#443 ·
Maintainers usually reply within 1 day