Skip to content
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] CacheClassMetadataFactory performance #28272

Closed
martiis opened this issue Aug 26, 2018 · 5 comments
Closed

[Serializer] CacheClassMetadataFactory performance #28272

martiis opened this issue Aug 26, 2018 · 5 comments

Comments

@martiis
Copy link
Contributor

martiis commented Aug 26, 2018

Symfony version(s) affected: 4.1.3 (havent test other)

Description
IDK if it was discussed in the past but recently i was checking symfony serializer (ObjectNormalizer) performance, and in dev env it was faster than in prod. I have configured opcache just like in docs, xdebug disabled.

My test is serializing 1000 objects with various scalar value properies + one property is an object + one property holds 5-15 small objects in array.

Serialize took about 2184 ms prod env, 152 ms dev env.

How to reproduce
My actual test https://github.com/martiis/symfony-serialization-bench/blob/master/src/Command/BenchSymfonySerializerCommand.php#L78

Possible Solution
Found out that in prod CacheClassMetadataFactory does not keep loaded classes like ClassMetadataFactory and everytime it goes into file system checking cache. I thought opcache should fix this but it didint or maybe i missed something? if I put $loadedClasses property in CacheClassMetadataFactory performance back as in dev env.

Additional context
Opcache config

opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.interned_strings_buffer = 16
@martiis
Copy link
Contributor Author

martiis commented Aug 27, 2018

Blackfire graphs:

@GuilhemN
Copy link
Contributor

A radical but efficient solution would be #22051 :)

@nicolas-grekas
Copy link
Member

There's a regression identified in #28457 (comment).
Someone would need to have a look.

@martiis
Copy link
Contributor Author

martiis commented Sep 24, 2018

This will improve perf, but later I noticed that I haven't enabled opcache for cli, which improved performance (cant remember by how much atm, but near as dev env), because PhpFilesAdapter is only working with opcache enabled, else fallbacks to filesystem adapter. CacheClassMetadataFactory always goes into cache adapter, thats why my test was so slow.

@xabbuh
Copy link
Member

xabbuh commented Sep 24, 2018

let's close then as the issue seems to be resolved

@xabbuh xabbuh closed this as completed Sep 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants