Repository navigation
Conversation
When Config\Modules::$composerPackages has no filters defined (the default behavior in almost all applications), all PSR-4 prefixes from Composer belong to installed packages. Skip the expensive InstalledVersions::getAllRawData() scanning, versions array_merge, and triple-nested str_starts_with matching loop when neither 'only' nor 'exclude' is configured. When package filtering is configured, the original full validation logic is preserved with zero BC breaks.
gr8man
force-pushed
the
perf/autoloader-composer-namespaces
branch
from
November 1, 2026 22:41
8863a59 to
26612d5
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In
Autoloader::loadComposerNamespaces(), whenever Composer namespaces are loaded, the autoloader was unconditionally callingInstalledVersions::getAllRawData(), performing anarray_mergeacross all installed package versions, and executing a triple-nested loop testingstr_starts_with($path, $installPath)for every single PSR-4 namespace.In almost all applications,
Config\Modules::$composerPackagesis empty (default configuration with neitheronlynorexcludespecified). In this default state, all registered PSR-4 prefixes from Composer already belong to installed packages (or the root package) and can be registered directly into$this->prefixeswithout scanningInstalledVersions.This PR adds a fast-path for the default configuration:
$only === [] && $exclude === []upfront.$this->prefixes, skippingInstalledVersions::getAllRawData(),array_merge, and the triple-nestedstr_starts_with()matching loop entirely.onlyorexclude), the original full validation logic is preserved with zero BC breaks.Benchmark (10,000 iterations)
loadComposerNamespaces(): 1496.44 ms (~0.150 ms per request)loadComposerNamespaces(): 144.24 ms (~0.014 ms per request)Checklist: