-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] Add a way to disable ClassDiscriminatorResolver #28537
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
Labels
Comments
Someone asked me to test with Symfony/Serializer: 4.2@dev. I have the same problem (~120ms) |
Here is a profile comparison about using the Profiled code: egeloen/ivory-serializer-benchmark#8 $noop = class implements ClassDiscriminatorResolverInterface {
public function getMappingForClass(string $class): ?ClassDiscriminatorMapping
{
return null;
}
public function getMappingForMappedObject($object): ?ClassDiscriminatorMapping
{
return null;
}
public function getTypeForMappedObject($object): ?string
{
return null;
}
} |
See also #28457 |
nicolas-grekas
added a commit
that referenced
this issue
Oct 20, 2018
…ult) This PR was merged into the 4.1 branch. Discussion ---------- [Serializer] Reduce class discriminator overhead | Q | A | ------------- | --- | Branch? | 4.1 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28537 | License | MIT | Doc PR | N/A This try to fix the overhead added by class discriminator feature. Here is a 4.1 vs this PR comparison: https://blackfire.io/profiles/compare/20ead249-0e98-430f-9b8d-906f464b1854/graph And a 3.4 vs this PR comparison: https://blackfire.io/profiles/compare/7e402dde-4a54-4053-a12e-d3d6891afc02/graph Commits ------- 326c267 [Serializer] Reduce class discriminator overhead
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected: 4.1.4
Description
I had a performance issue on migrating my project from Symfony3.4 to Symfony4.1.
I mainly use Serializer to serialize data (through ObjectNormalizer).
After doing several blackfire analyses, I have found that problem was due to ClassDiscrimintatorResolver (#24375) which is enable by default whereas I don't need it.
To fix the problem, I had to create a Custom ObjectNormalizer and set $this->classDiscriminatorResolver to null. Not very elegant but I had a huge boost with this modification and SF4 serializer (now 90ms, 120ms without this modification) is now faster than SF3.4 (97ms).
Possible Solution
A possible solution should be to disable classDiscriminatorResolver if
framework.serialiazer.discriminator_class_mapping
is not set.The text was updated successfully, but these errors were encountered: