-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Serializer] add a local cache to CacheClassMetadataFactory #28457
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] add a local cache to CacheClassMetadataFactory #28457
Conversation
Can anyone see why 5.5 fails? |
Seems bad idea to decorate psr caches with local caches. Memory leaks, lost control over caches in user space. |
I'm not sure it is worth it to test that the local cache is actually used. Such tests are very hard to maintain. |
Yeah, I thought the same.
…On Thu, 13 Sep 2018, 14:21 Kévin Dunglas, ***@***.***> wrote:
I'm not sure it is worth it to test that the local is actually used. Such
tests are very hard to maintain.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#28457 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAmK8D4rBfgmSGsKgvzi6aVMrEU9VjUeks5ualvmgaJpZM4WmxXX>
.
|
reverted test change |
Can this implement the kernel |
Hello, thanks for the PR. I'm not sure this is the right fix. Here is why: I checked out egeloen/ivory-serializer-benchmark#11 and did a straight composer install: the perf number was not that different from others for SymfonyObjectNormalizerBenchmark. Here is a comparison profile before/after As you can see, the number of calls to THEN, once this is resolved, I noticed that IF ArrayAdapter is suited (ie sharing the same instance is fine), then we could/should chain an ArrayAdapter on top instead of inlining this logic here. To be confirmed by numbers. PS:
not needed as class info is static, and the number of files is finite, so this wouldn't qualify as a memory leak to me. |
Hey @nicolas-grekas thanks for the detailed review! I'll take another look later! |
head of 3.4 or 4.x? |
Master |
duh thanks. have reproduced that performance decrease between 3.4 and master. |
So which commit caused the speed slowdown? |
Haven't looked yet as I've been on vacation!
…On Sun, 23 Sep 2018, 18:03 Asmir Mustafic, ***@***.***> wrote:
So which commit caused the speed slowdown?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#28457 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAmK8NhxaWQIafa-Ke_HHGx4NVU68tRpks5ud77agaJpZM4WmxXX>
.
|
@bendavies What's the status of this PR? |
@fabian performance decrease in symfony 4 needs investigating. i haven't had time yet, but plan to. |
ok, thanks for the heads-up. |
i'm taking a look |
https://blackfire.io/profiles/compare/890441d8-bfb6-430b-a56f-a96fe137cd9f/graph So the local cache in this PR fixes the issue, reducing the cache lookups. Optimally, we could:
|
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Serializer/Normalizer/ObjectNormalizer.php#L114 looks faulty too. This method is called for every attributes, but could be called only one time per object. WDYT @sroze. |
@dunglas good spot |
@nicolas-grekas @dunglas feedback on my last comment? |
I'd be happy to have a new bench once the patch is applied to see if the perf issue remains after :) |
I did some profiling. All where run using the following command: First I did a profile to see which of arrayAdapter or apcuAdapter is the best: Symfony 3.4 vs this PR: master vs this PR rebased: IMHO, we should work on reducing the EDIT : I forgot to disable serialization in arrayAdapter for my first comparison. Here are the new results: I forgot to disable serialization in the arrayAdapter. Here are the new comparison : https://blackfire.io/profiles/compare/d6b3637a-5c0b-4bdb-bcc2-db8a0b77667a/graph. EDIT2 : I opened a PR based on those results: #28889 |
as an aside, |
I closed by mistake, but was going to ask if #28889 does solve this now? |
indeed #28889 fixes the root cause. |
ping @dunglas
This PR improves the performance of the Serializer in certain benchmarks,
https://www.goetas.com/blog/whats-new-in-jmsserializer-v20/ (https://github.com/goetas/ivory-serializer-benchmark) to be specific.
FYI, egeloen/ivory-serializer-benchmark#11 was also applied to obtain the results below.
Before PR:
After PR:
The improvement of the Symfony Object and GetSet normalizer benchmarks is significant.
Testing the change was a bit annoying, as you can see. Any better ideas?