jalogut / magento2-deployer-plus

Tool based on deployer.org to perform zero downtime deployments of Magento 2 projects
GNU General Public License v3.0
200 stars 59 forks source link

Enhancement: Run Composer optimize autoloader after DI compile #40

Closed erfanimani closed 4 years ago

erfanimani commented 5 years ago

I haven't tested it, but apparently composer dumpautoload -o --apcucan be run after DI compile to speed up PHP class lookups. Might be worth looking into.

"File system is a bottleneck - make sure composer is optimized and class map is generated after setup di compile. Refer to this tweet of mine:"

https://twitter.com/IvanChepurnyi/status/1179280000400465920

erfanimani commented 5 years ago

Will test for a while with the following in deploy.php, and report back.

set('composer_options', '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --no-suggest'); // Removing optimization from here, since we're now doing it separately.
task('optimize-autoloader', function () {
    run('cd {{release_path}} && {{bin/composer}} dump-autoload --optimize --apcu');
});

after('files:compile', 'optimize-autoloader');
osrecio commented 4 years ago

Can you create a PR @erfanimani ?

I like the idea!

erfanimani commented 4 years ago

Yes, it works good. Haven't benchmarked it, but I'll create a pr when I get the chance.

stu177 commented 4 years ago

@erfanimani Did you ever get round to benchmarking this? Very curious to see what impact this has.

erfanimani commented 4 years ago

@stu177 I just created a PR, but haven't actually benchmarked it. @IvanChepurnyi might know

IvanChepurnyi commented 4 years ago

See this Blackfire profiles: https://twitter.com/IvanChepurnyi/status/1179318211076087808 When autoload is dumped before compile step - composer will execute file_exists check on every auto-generated class resolving in huge I/O hit.