mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Significant performance degradation with enable_lazy_ghost_objects: true
#7259
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @javer on GitHub (Nov 25, 2023).
Bug Report
Summary
After updating ORM from 2.15.2 to 2.17.1 and turning on
enable_lazy_ghost_objectsas it's suggested I've noticed a significant performance degradation during test suite running. The overall suite became slower by noticeable 30%. Localizing the slow spot I've found that ProxyReferenceRepository::load() now takes 50 seconds in total instead of the previous 3.86 seconds, i.e. became 13x slower.Tracking down
ProxyReferenceRepository::load()->ProxyReferenceRepository::unserialize()I've found thatEntityManager::getReference()became 23x slower (2.055 seconds -> 47.888 seconds in total). This real project has hundreds of entities and complex relations between them. During running test suite with 1k+ scenarios a lot of fixtures are generated, saved and loaded (including references):I've created a test command to reproduce the issue, and running it in the same project I get:
I've created a small reproducer: https://github.com/javer/doctrine-orm-lazy-ghost
It's a fresh Symfony 6.3 project with one additional commit:
36a3e20b93Running
bin/console app:test:ormI have the following results:Slowdown numbers are not so high as in a real project, but there is only one simple entity without any relations, and no save/load operations, only getting references. Even in this simple case
ProxyFactory::getProxy()slowdown by almost 4x is too expensive for usingenable_lazy_ghost_objects.Taking into account that
enable_lazy_ghost_objectswill be alwaystruein ORM 3.0 I think it's worth fixing it.How to reproduce
Expected behavior
Turning on
enable_lazy_ghost_objectsshouldn't have a noticeable impact on the performance.