Repository navigation
perf(joinpoint): create method and function reflection on first use - #772
Merged
Merged
Conversation
…n first use Like ClassFieldAccess, the joinpoints no longer reflect in their constructors: - DynamicTraitAliasMethodInvocation resolves the original-body ReflectionMethod on the first call that reaches it - ReflectionFunctionInvocation creates its ReflectionFunction in getFunction() - ReflectionConstructorInvocation creates the class and constructor reflection on the first proceed()/getConstructor()/getScope() Joinpoints whose advices never need reflection (an around advice that does not proceed) build none. Hot-path numbers are unchanged within noise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAJm7FNJjQyTtSYtFtJdMR
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #772 +/- ##
============================================
- Coverage 98.19% 98.19% -0.01%
Complexity 1910 1910
============================================
Files 113 113
Lines 4999 4995 -4
============================================
- Hits 4909 4905 -4
Misses 90 90 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…cation Creating the object always needs the class and constructor reflection, and the lazy version measured slower: +20-25% on the first call when the constructor runs (8/8 interleaved processes), +3% on repeated calls. The method and function joinpoints stay lazy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YAJm7FNJjQyTtSYtFtJdMR
lisachenko
marked this pull request as ready for review
October 21, 2026 10:52
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
ClassFieldAccessalready creates itsReflectionPropertyonly when someone asks for it. This PR does the same for the method and function joinpoints, so their constructors no longer build reflection:DynamicTraitAliasMethodInvocation: theReflectionFunction+ReflectionMethodpair that finds the original method body is now resolved on the first call that reaches the body (??=inproceed()), not in the constructor.getMethod()was already lazy.ReflectionFunctionInvocation: stores the function name and creates theReflectionFunctioningetFunction(). The original function is called through its first-class callable, so it never needs reflection to run.If an advice never needs reflection (for example an around advice that returns a cached value without calling
proceed()), no reflection is created at all.ReflectionConstructorInvocationwas tried too and then reverted (second commit). Creating the object always needs the class and constructor reflection, and the lazy version measured 20–25% slower on the first call when the constructor runs (8 of 8 interleaved processes), plus 3% on repeated calls. It stays eager, andsrc/Aop/AGENTS.mdnotes why.Behaviour change on internal classes: a closure without a scope class, or an unknown function name, now fails on first use instead of at construction. The existing test was updated to match, and new tests check that reflection stays lazy.
Measurements
These numbers come from a sandbox, with master and the PR loaded in one process and timed interleaved.
First call (joinpoint creation + call), around advice:
Repeated calls (
composer test:performance, 5 alternating runs, median ratio against a plain call): every case matches master within ±0.3 and stays well within budget, e.g. method 10.6 → 10.9, function 10.9 → 11.1, method + around 14.2 → 14.2, function + around 16.2 → 16.3.Checklist
type(scope): summary)composer checkpasses: phpstan and cs are clean, andtests/Aop/Frameworkpasses. In this sandbox, functional/console tests fail andConstructorExecutionTransformerTestsegfaults the same way on master, so these are sandbox problems. CI runs the full suite.🤖 Generated with Claude Code
https://claude.ai/code/session_01YAJm7FNJjQyTtSYtFtJdMR