Skip to content

[Serializer] CacheClassMetadataFactory performance #28272

@martiis

Description

@martiis

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions