Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for performance improvements in Symfony 5.0 #34708

Closed
javiereguiluz opened this issue Nov 29, 2019 · 17 comments
Closed

Check for performance improvements in Symfony 5.0 #34708

javiereguiluz opened this issue Nov 29, 2019 · 17 comments

Comments

@javiereguiluz
Copy link
Member

Description
The *.4 Symfony versions are always the slowest in a branch (e.g. 4.4 is the slowest 4.* version) because of all the deprecated features.

For the same reason, the *.0 versions are usually the fastest Symfony versions. However, for 5.0 this didn't happen. See phpbenchmarks.com results:

symfony-top-10-performance

Maybe we could do some Blackfire profiling to find possible ways of improving Symfony 5.0 performance. Thanks!

@stof
Copy link
Member

stof commented Nov 29, 2019

The symfony 5.0 benchmark has APP_ENV=dev in their .env file. So it looks like they benchmarked the dev environment, not the prod environment: https://github.com/phpbenchmarks/symfony/blob/d42d5dc67d54de676460f9b91b3bb326b04696b3/.env#L17

@stof
Copy link
Member

stof commented Nov 29, 2019

btw, the 4.4 branch of the benchmark has the same issue

@javiereguiluz
Copy link
Member Author

Thanks Christophe! I've sent a PR to fix it for 5.0 (phpbenchmarks/symfony#13). Let's see what do they think about that.

@steevanb
Copy link

Hi, i'm phpbenchmarks owner.

Benchmarks were done in PROD env, be sure of that: https://github.com/phpbenchmarks/symfony/blob/5.0_hello-world/.phpbenchmarks/initBenchmark.sh#L22

If they were done in DEV env, believe me, results will be really slower ;)

@stof
Copy link
Member

stof commented Nov 29, 2019

@steevanb composer dump-env prod does not mean that the APP_ENV variable will be forced to be set to prod. It means that will will load .env and .env.prod (and the .local overrides) to generate the optimized PHP file to skip the .env parsing.

@nicolas-grekas
Copy link
Member

composer dump-env prod does not mean that the APP_ENV variable will be forced to be set to prod

it still means that the default is going to be prod, so that's OK, it works for the purpose

@steevanb
Copy link

steevanb commented Nov 29, 2019

@stof Are you sure about it? On all my Symfony projects, I don't have .env.prod, and composer dump-env prod define APP_ENV to prod in .env.local.php.

@stof
Copy link
Member

stof commented Nov 29, 2019

hmm, indeed, I forgot that dump-env has a special case for APP_ENV

@steevanb
Copy link

To be sure there is no problem with this benchmarks, i've relaunched Symfony 5.0 Hello World benchmark with 3 test cases:

  1. APP_ENV=prod, APP_DEBUG not defined
  2. APP_ENV=prod, APP_DEBUG=false
  3. APP_ENV=dev, APP_DEBUG=true

Line Best is the best time before this tests, it's time you can see on phpbenchmarks.com.
Line Actual is time for this benchmark, with the new configuration.

APP_ENV=prod, APP_DEBUG not defined

Calls  Fails Total time rq/sec ms/rq
Best 50000 0 53609 932.67 1.072
Bench 50000 0 68518 729.73 1.370

APP_ENV=prod, APP_DEBUG=false

Calls  Fails Total time rq/sec ms/rq
Best 50000 0 53609 932.67 1.072
Bench 50000 0 63742 784.42 1.275

APP_ENV=dev, APP_DEBUG=true

Calls  Fails Total time rq/sec ms/rq
Best 50000 0 53609 932.67 1.072
Bench 50000 0 110887 450.91 2.218

As you can see, results are very similars when APP_DEBUG is not defined or is =false.

But with APP_ENV=dev, results are slower.

Too me, results available on phpbenchmarks.com are the right ones: APP_ENV is well defined to prod and APP_DEBUG does not seems to change anything.

@javiereguiluz
Copy link
Member Author

@steevanb thanks for double checking the benchmarks (and thanks for creating and maintain that site!). We'll look for other posible solutions to improve performance.

@steevanb
Copy link

Thank you! If you need help to improve performances, you can contact me ;)

@stof
Copy link
Member

stof commented Nov 29, 2019

As you can see, results are very similars when APP_DEBUG is not defined or is =false.

that's expected, as the default value for APP_DEBUG is false when running in prod environment.

@steevanb
Copy link

Yes, this test was just here to prove it ;)

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Dec 10, 2019

Symfony 4.0 provided a significant redesign of the DI: case insensitive service ids, private services by defaut, etc.
Symfony 5.0 doesn't have similar things to remove.
The most significant perf benefit should come from preloading now (which has quite some issues right now in PHP 7.4 and would need improved support also in Symfony 5.1)
Not sure there is anything to keep track of here.

@vudaltsov
Copy link
Contributor

@nicolas-grekas , I think, the question is why it is slower, not why it's not faster.

@bastnic
Copy link
Contributor

bastnic commented Jan 7, 2020

Cf #35252

@javiereguiluz
Copy link
Member Author

I'm closing this because we didn't find any obvious error neither in Symfony 5.0 nor in the benchmarks. So, let's keep improving performance in separate issues and PRs. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants