Skip to content

[perf] Look up class rename by name in RenameClassRector const-fetch guard - #8735

Merged
TomasVotruba merged 1 commit into
mainfrom
tv-perf-rename-class-const-lookup
Oct 20, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
tv-perf-rename-class-const-lookup

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Same shape as #8734, applied to the class-rename path.

RenameClassRector::shouldSkipClassConstFetchForMissingConstantName() scanned the whole configured rename map, running isName() on each entry per fully-qualified class-const fetch node. But a node has a single name and the map is keyed by old class, so the entry can be found with a direct hash lookup - the same lookup ClassRenamer already uses for the rename itself. Upgrade sets configure thousands of class renames, so the scan was a per-node linear cost over every class-const fetch, and isName() on a fully-qualified node is not cheap.

Behaviour

Equivalent: hasClass() above already uses $fullyQualified->toString(), and the actual rename matches by the same case-sensitive key, so a canonical-FQCN map resolves identically. Covered by skip_rename_target_interface_class_const_fetch_not_found.php.inc.

Numbers

bench/rename_class_const_fetch_lookup_bench.php (500 renames, 150 non-matching const fetches, CPU time):

us/call
before 1271.9
after 2.0

Scales with the configured rename-map size. Full rules-tests/Renaming (107 tests) green, PHPStan and ECS clean.

…guard

shouldSkipClassConstFetchForMissingConstantName() scanned the whole configured rename map with isName() per fully-qualified class-const fetch node. A node has a single name and the map is keyed by old class, so this is a direct hash lookup - the same lookup the rename itself already does.

Upgrade sets configure thousands of class renames, so the scan was a per-node linear cost over every class-const fetch.

bench/rename_class_const_fetch_lookup_bench.php (500 renames, 150 non-matching const fetches): 1271.9 -> 2.0 us/call.
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