Skip to content

⚡ Find the classes of all namespaces in one scan - #294

Open
aszenz wants to merge 1 commit into
thecodingmachine:masterfrom
aszenz:fix-scan-namespaces-once
Open

aszenz wants to merge 1 commit into
thecodingmachine:masterfrom
aszenz:fix-scan-namespaces-once

Conversation

@aszenz

@aszenz aszenz commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

GraphQLiteCompilerPass::getClassList() made a new ComposerFinder for each configured controllers and types namespace. kcs/class-finder filters the PSR-4 prefixes by the first part of the namespace only, so each finder walks every PSR-4 directory of the root namespace (for example all of src/). With N namespaces, the same files are walked N times during each container build.

This change finds the classes of all namespaces with one finder, then splits them per namespace with the same rule that kcs/class-finder uses (the class namespace is the namespace or a sub-namespace of it). graphqlite's SchemaFactory does the same: one finder for all namespaces.

Measured on a Symfony app with 6 namespaces (3 controllers, 3 types) and about 30,000 classes in an optimized class map:

before after
cold dev container build 8.3 s 4.9 s

The public services and the dumped schema are the same before and after. With alekitto/class-finder#28 as well, the build takes 4.6 s.

Tests and PHPStan pass.

The compiler pass made a new ComposerFinder for each controllers and types
namespace. Each one walks every PSR-4 directory of the root namespace, so
the same files were walked once per configured namespace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant