Doctrinebundle: Symfony cache clear compile 2 container caches with this bundle

Created on 21 Jan 2018  路  4Comments  路  Source: doctrine/DoctrineBundle

Since the passage of a project in 3.3, I noticed that the cache:clear took much more time, and even more in 3.4, but by reading the post of @fabpot on the performance of different Symfony versions, the version 3.4 was the slowest because deprecated features was probably one of the reasons.

However, I noticed that I had 2 cache folders for the container in the var/cache/dev folder and the var/cache/dev/srcDevDebugProjectContainer.php file very light now. My project being quite big, I get 1013 PHP files in each cache folder for the container.

So I used the skeleton version in 3.3 and 3.4 to simplify the analysis.

composer create-project symfony/skeleton:"^3.4" . --prefer-dist

The result of the cache:clear command: a single cache folder for the container.

By adding doctrine orm:

composer require doctrine/doctrine-bundle doctrine/orm --prefer-dist

The result of the cache:clear command: 2 cache folders for the container containing the same files (92 files each).

For a small project, the double compilation of the container does not really feel, but on a big project, times explode. To give you an idea, currently with Symfony 3.4 in PHP 7.1 on Windows 10 64bit, with an SSD, the time for the cache:clear command is 2m11s, knowing that the messageClearing the cache for the dev environment with debug true appears after 33s. Before I had a delay of 8/10s for the message, and a total of about 50s. Of course, with a linux distribution on the same machine you divide by more than 2 the execution time.

In addition, my functional tests take more time corresponding nearly the same gap for compiling the duplicate cache.

Before creating this issue, I tried to find the problem, but I did not find the solution. However, if it helps, the problem appears when you add the config doctrine.orm (even with an empty config in this section), allowing to start the ORM configuration in the bundle extension.

PS. Given that I do not know if the problem comes from the Symfony cache compiler, Symfony Doctrine Bridge or Doctrine Bundle, I created this issue here because the problem is related to this bundle.

Most helpful comment

Actually something is really strange. For some reason the cache warmers are run twice on cache:clear.

When the container hash did NOT change the warmUp($cacheDir) receives

  • /var/cache/dev and %kernel.cache_dir% is /var/cache/dev
  • /var/cache/de_ and %kernel.cache_dir% is /var/cache/dev

When the container hash changed.

  • /var/cache/de_ and %kernel.cache_dir% is /var/cache/de_
  • /var/cache/de_ and %kernel.cache_dir% is /var/cache/de_

All 4 comments

There are two containers because the old one is not removed immediatly anymore since https://github.com/symfony/symfony/pull/25190

So symfony does not create two containers at once. What happened is that the container before adding the doctrine bundle is still there after you added the doctrine bundle. This is why you see two containers.

Actually something is really strange. For some reason the cache warmers are run twice on cache:clear.

When the container hash did NOT change the warmUp($cacheDir) receives

  • /var/cache/dev and %kernel.cache_dir% is /var/cache/dev
  • /var/cache/de_ and %kernel.cache_dir% is /var/cache/dev

When the container hash changed.

  • /var/cache/de_ and %kernel.cache_dir% is /var/cache/de_
  • /var/cache/de_ and %kernel.cache_dir% is /var/cache/de_

@Tobion Thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KartaviK picture KartaviK  路  4Comments

dmaicher picture dmaicher  路  6Comments

Sjeijoet picture Sjeijoet  路  4Comments

spdionis picture spdionis  路  5Comments

smurfy picture smurfy  路  7Comments