Skip to content

[perf] Only process catch stmts PHPStan skipped in PHPStanNodeScopeResolver, run decorating visitors once - #8738

Merged
samsonasik merged 1 commit into
mainfrom
perf-fill-scope
Oct 20, 2026
Merged

samsonasik merged 1 commit into
mainfrom
perf-fill-scope

Conversation

@samsonasik

@samsonasik samsonasik commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Every Catch_ node made the resolver call the whole processNodes() again on that catch block's body.

PHPStan already walks catch bodies itself with a more precise scope, right after the callback, and overwrites the result.

The recursion also re-ran the decorating node visitors, so the work doubled at each nesting level.

Here the benchmark by run script: bench/php_stan_node_scope_resolver_catch_bench.php

Run main CPU This PR CPU Change
1 10.7229s 6.1215s -42.9%
2 10.9962s 6.1685s -43.9%
3 11.1088s 6.1737s -44.4%
Avg 10.9426s 6.1546s -43.8%

@samsonasik

Copy link
Copy Markdown
Member Author

All green 🎉 @TomasVotruba I am merging it ;)

@samsonasik
samsonasik merged commit 40a01f1 into main Oct 20, 2026
49 checks passed
@samsonasik
samsonasik deleted the perf-fill-scope branch October 20, 2026 17:20
@TomasVotruba

Copy link
Copy Markdown
Member

Nice work 👍

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.

2 participants