Skip to content

[perf] Cache skip-filtered rules per node class for the current file in RectorRegistry::forNodeAndFile() - #8860

Merged
TomasVotruba merged 3 commits into
mainfrom
cache-skip
Oct 27, 2026
Merged

TomasVotruba merged 3 commits into
mainfrom
cache-skip

Conversation

@samsonasik

Copy link
Copy Markdown
Member

RectorRegistry::forNodeAndFile() checks the Skipper for every subscribed rule on every visited node, on every pass. This PR caches the filtered rules per node class for the current file, since the skip result only depends on the rule and the file path.

Bench (bench/rector_registry_for_node_and_file_bench.php):

before after
CPU 0.235 s 0.062 s
shouldSkipRectorAndFile() calls 153,405 2,688

@samsonasik

Copy link
Copy Markdown
Member Author

@TomasVotruba ready 👍

Comment thread src/Application/RectorRegistry.php Resolved
@samsonasik
samsonasik requested a review from staabm October 27, 2026 15:09
@TomasVotruba
TomasVotruba merged commit 3a05e21 into main Oct 27, 2026
50 checks passed
@TomasVotruba
TomasVotruba deleted the cache-skip branch October 27, 2026 15:19
@TomasVotruba

Copy link
Copy Markdown
Member

Looks good, thanks

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.

3 participants