Skip to content

[perf] Skip call reflection when no closure/arrow/array arg - #8711

Merged
TomasVotruba merged 1 commit into
mainfrom
skip-call-reflection-without-closure-array-arg
Oct 19, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
skip-call-reflection-without-closure-array-arg

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

CallLikeReflectionNodeVisitor decorates call arguments and runs on every CallLike node during metadata decoration. It resolved the function-like reflection for every call that has arguments - but that reflection is only used to decorate a Closure/arrow-fn arg passed to a variadic callable param, or an array arg passed to a param that cannot hold a Closure. A call like strlen($s) or $this->foo($x, $y) - the overwhelming majority - paid for the resolve and decorated nothing.

A cheap node-only pre-check (hasClosureArrowOrArrayArg) now bails before resolveFunctionLikeReflectionFromCall() when no argument is a Closure, ArrowFunction, or Array_. Both decoration helpers already no-op without such an arg, so the behavior is unchanged.

Full test suite passes (4988 tests).

Bench included (bench/call_like_reflection_visitor_bench.php), driving enterNode() over 240 ordinary calls. CPU per call, two runs each:

CPU us/call
before ~9-15
after ~1.4-2.2

~6-7x faster on that path, and it is on the hot decoration traversal that visits every call in every file.

@TomasVotruba
TomasVotruba merged commit 65817d3 into main Oct 19, 2026
48 of 49 checks passed
@TomasVotruba
TomasVotruba deleted the skip-call-reflection-without-closure-array-arg branch October 19, 2026 09:21
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