Performance regression in cache warmup
I recently upgraded to 9.5 and noticed that the cache warmup became significantly slower. After some investigation, I found that the slowdown actually started in 9.1.2.
With 9.1.1, clearing the cache gives:
[INFO] "AutoMapper\Symfony\Bundle\CacheWarmup\CacheWarmer" completed in 15262.90ms.
Starting from 9.1.2 (and still in 9.5), the same operation takes much longer:
[INFO] "AutoMapper\Symfony\Bundle\CacheWarmup\CacheWarmer" completed in 37221.69ms.
I tried to investigate the cause but didn’t manage to find anything conclusive.
Environment: PHP: 8.2.29 Symfony: 6.4.24
Do you have any idea what change could have introduced this?
Thanks a lot for your help!
It may be the removal of cache for getting the property info metadata.
Basically we were using the property info services from symfony before this change, and we now use our own services, mainly because :
- we don't want to influence our metadata based on other configs / hijack
- we don't want to introduce double cache (property info + generated mapper) as it can cause a lot of trouble for debugging when something is not correct and we don't know why
Would be nice to have a profile of what takes all of this second, how many mapper are generated (should be a lot given this duration) ?
I ran some tests to profile the generation duration. We generate 54 automappers in total, but for my benchmark I focused on our largest entity.
The bottleneck seems to come from type extraction. In version 9.1.1, the second call to type extraction performed by the buildMappers is noticeably faster, likely thanks to caching.
I think we may add an option to cache those extractor in next version