Skip to content

[perf] Skip use-imports resolve on preslash narrow path - #8538

Merged
TomasVotruba merged 1 commit into
mainfrom
perf-skip-use-resolve-on-preslash
Oct 8, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
perf-skip-use-resolve-on-preslash

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

In ObjectTypeSpecifier::narrowToFullyQualifiedOrAliasedObjectType(), $uses = $this->useImportsResolver->resolve() ran on every call, but the result is only read inside the ! $withPreslash branch.

The hot path is NodeTypeResolver::getType(), which calls this method with withPreslash: true for every ObjectType result - so resolve() ran and its result was discarded. resolve() walks the namespace and filters all file statements (FileNode::getUsesAndGroupUses()), uncached.

Moving the call inside the branch where it is used removes that work from the preslash path. Behavior is identical.

Measured on a serial run over rules/: this path fires ~27k times.

@TomasVotruba TomasVotruba changed the title [TypeDeclaration] Skip use-imports resolve on preslash narrow path [perft] Skip use-imports resolve on preslash narrow path Oct 8, 2026
@TomasVotruba TomasVotruba changed the title [perft] Skip use-imports resolve on preslash narrow path [perf] Skip use-imports resolve on preslash narrow path Oct 8, 2026
@TomasVotruba
TomasVotruba merged commit 38507ee into main Oct 8, 2026
50 checks passed
@TomasVotruba
TomasVotruba deleted the perf-skip-use-resolve-on-preslash branch October 8, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant