-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Fix cache in MetadataAwareNameConverter #35252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Serializer] Fix cache in MetadataAwareNameConverter #35252
Conversation
76db25e
to
4862535
Compare
dfd691f
to
199fda6
Compare
src/Symfony/Component/Serializer/NameConverter/MetadataAwareNameConverter.php
Outdated
Show resolved
Hide resolved
`isset` is used to test existence of values that is `null` by default, which result to always bypass the cache and force to do the calculate all the time. This is a critical perf improvement in prod mode for an api. Ref symfony#35085
199fda6
to
6449f92
Compare
FYI, it depends of the number of property in the response, so could be way more than 5% (I got 8 in a previous one). |
@bastnic Is this behavior documented somewhere? These results are impressive, I'm curious where you learned that |
@natebrunette IIRC it’s not about the benchmark of these functions but about checking issue on null even if the key exists. Not the key is checked instead of the value which only forces a recalculate if really needed. The perf boost comes from correct usage not one function over the other. Am I right @bastnic? |
I couldn't say it better. Thanks @OskarStark. |
Thank you @bastnic. |
…nic) This PR was merged into the 4.4 branch. Discussion ---------- [Serializer] Fix cache in MetadataAwareNameConverter | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | ref #35085 | License | MIT | Doc PR | `isset` is used to test existence of values that is `null` by default, which result to always bypass the cache and force to do the calculation all the time. This is a serious perf improvement in prod mode for an api.   Commits ------- 6449f92 [Serializer] Fix cache in MetadataAwareNameConverter
isset
is used to test existence of values that isnull
by default, which result to always bypass the cache and force to do the calculation all the time.This is a serious perf improvement in prod mode for an api.