Repository navigation
refactor(Type): keep one TypeContextFactory per TypeResolver - #2364
DerManoMann merged 3 commits into
Conversation
Docblock and reflection type contexts now come from two factories created with the resolver.
… source file Native types arrive fully qualified, so the context only needs the declaring class for self, static and parent.
DerManoMann
left a comment
There was a problem hiding this comment.
Thanks for this, and for the numbers.
The two new tests fail with the lowest dependencies, which install symfony/type-info 7.3.8:
TypeContextFactoryonly caches the use statements from 8.1 on, so on 7.x and 8.0 the file is still read once per property. The change is fine there, it just does not help. Can the test be skipped when the factory has no cache?- In 7.3
TypeContext::getCalledClass()normalizes the class name against the namespace, so a fully qualified name comes back with the namespace twice andself/parentresolve to a class that does not exist. Building theTypeContextby hand depends on how the installed version stores it.
Can we drop the second commit and keep a second factory for the native types instead, as in the issue? That costs one extra read per class, and it works the same on every version we support.
Restore the native TypeContextFactory and skip the cache regression test when Symfony has no use-statement cache.
|
Thanks for catching this. I've reverted that approach and restored the two separate factories from the issue. The cache test now skips when I also retested the revised changes together with #2365 against our API. Median generation time dropped from 20.0 s to 11.1 s on the Docker Desktop bind mount. |
|
Thanks @leo-pansonato |
(cherry picked from commit a78b362)
Closes #2363
Overview
TypeResolvercreated a newTypeContextFactoryfor every reflector it resolved. Symfony versions with a use-statement cache discarded it with each instance, so the same class source file was read again for every property. This adds noticeable overhead on slower filesystems, such as Docker Desktop bind mounts.Changes
TypeResolverkeeps separate docblock and native reflection context factories for its lifetime.selfandparentresolution is covered on every supported TypeInfo version.Validation