symfony: PHPUnit tests almost 300% slower after Symfony update

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.10

Our project was running v3.2.6 and since it isn’t supported anymore we wanted to switch to Symfony 3.3. We created a new branch based on our master branch and made some changes to the code (removing deprecated stuff, etc.) but no major changes.

When running the tests of our project in the new branch it takes 15 minutes and 26 seconds whereas it only takes 6 minutes and 30 seconds in the master branch.

I found this issue: https://github.com/doctrine/annotations/pull/135#issuecomment-317174020 and we updated our dependency to doctrine/annotations from 1.4.0 to 1.5.0.

This already worked, it made our tests 5 minutes faster, so now it only takes 10 minutes and 50 seconds.

Type Duration
master 6 minutes 30 seconds
update-branch 15 minutes 26 seconds
update-branch (updated annotations) 10 minutes 50 seconds

For all those tests I deleted the cache folders beforehand, did a composer install, etc. so I always have the same preconditions.

In the linked PR from doctrine/annotations @Ocramius said

as for the performance issue caused by multiple reset() or registerLoader() calls, that cannot be fixed without introducing BC breaks 😦

so is there nothing else that can be done to improve performance?

What we changed

  • replaced kernel.root_dir with kernel.project_dir (same for the methods getRootDir() in AppKernel)
  • removed trusted_proxies from config.yml and now calling it in the app.php and app_dev.php

But this alone shouldn’t be responsible for an execution time that is 4 minutes longer, right?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 57 (53 by maintainers)

Commits related to this issue

Most upvoted comments

A Blackfire profile would immediately stop the guess work that’s happening here, please provide one…

You could either try johnkary/phpunit-speedtrap to see which tests run slow, or use a profiler like XHProf or Blackfire

Something to note: I usually run my tests with kernel.debug = false as its quite a bit faster:

3.3.10, kernel.debug = true:

=> Time: 9.88 minutes, Memory: 2848.01MB
3.3.10, kernel.debug = false:

=> Time: 4.31 minutes, Memory: 1548.01MB

I cannot easily benchmark using 3.2 currently. But maybe the difference between debug and no-debug is bigger on 3.3 now?

If you just run a single test, you are able to profile that execution. But be sure to run the test with a warmed up cache

Maybe try https://github.com/dmaicher/doctrine-test-bundle. You can just use the “static cache” feature without the transactional connections.

This reduces the time for my phpunit testsuite by factor 4-5. Also the memory consumption is less than half.