perf(mapper): cache per-class reflection plans during hydration - #2276
Open
osbre wants to merge 5 commits into
Open
perf(mapper): cache per-class reflection plans during hydration#2276osbre wants to merge 5 commits into
osbre wants to merge 5 commits into
Conversation
osbre
requested review from
aidan-casey,
brendt and
innocenzi
as code owners
September 5, 2026 20:53
Benchmark ResultsComparison of Open to see the benchmark resultsNo benchmark changes above ±5%. Generated by phpbench against commit 981b7a0 |
osbre
force-pushed
the
perf/mapper-hydration
branch
from
September 5, 2026 21:00
1b87a8f to
e223c43
Compare
xHeaven
force-pushed
the
perf/mapper-hydration
branch
from
September 8, 2026 00:10
8e580bd to
981b7a0
Compare
xHeaven
requested changes
Sep 8, 2026
xHeaven
left a comment
Member
There was a problem hiding this comment.
I've added 2 failing tests, please fix those regressions.
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.
Hydrating rows into models now caches reflection metadata, primary key scans, and resolved mappers to avoid redundant per-row work.
Improvements
map()call) with a container-scoped#[Singleton], so the cache lives and dies with its container - no cross-container leaks. It implementsResettable, so workers callingresetContainer()between requests re-resolve mappers instead of holding ones built from unregistered dependencies.ObjectFactory::__construct()takes a third argument as a result.Performance Impact
2,000-row SQLite select
Model::all()50 users with nested relations
map()in a hydration loopPer call, steady state