aws / aws-sdk-php-symfony

Apache License 2.0
351 stars 89 forks source link

Non-negligible memory usage when not even using the client #59

Closed greg0ire closed 4 years ago

greg0ire commented 4 years ago

Please fill out the sections below to help us address your issue.

Version of AWS SDK for PHP?

3.98.0

Version of AWS Service Provider for Symfony?

2.0.1

Version of Symfony (bin/console --version in project dir)?

4.3.3

Version of PHP (php -v)?

7.1.28

What issue did you see?

When using any Symfony CLI command, every command is instantiated. If a command relies on a S3Client, the S3Client will be instantiated too, and this seems to use a lot of memory, because it is loading a huge json file.

Screenshot_2019-11-07 Untitled profile - Blackfire

Steps to reproduce

  1. Create a Symfony Command that requires an S3Client instance
  2. Run any command (can be another command)

Setting the service as lazy results in a 15% performance gain (thanks Blackfire).

chalasr commented 4 years ago

Symfony console commands can and should be lazy though :) https://symfony.com/doc/current/console/commands_as_services.html#console-command-service-lazy-loading https://symfony.com/doc/current/console/lazy_commands.html

greg0ire commented 4 years ago

Yes, I just figured I was doing it wrong: https://twitter.com/greg0ire/status/1192509418262401025 :P