
Here we will describe how to improve standard Magento 2 compilation in order to make it almost twice faster.
In several compilation components, such as Application code, Area, Interception and Interception Cache generators, Magento 2 scans filesystem looking for PHP classes, dependencies, etc.
We assumed that core Magento 2 modules do not change often and we can cache their list to avoid unnecessary filesystem scans.
In files:
setup/src/Magento/Setup/Module/Di/App/Task/Operation/ApplicationCodeGenerator.php
setup/src/Magento/Setup/Module/Di/App/Task/Operation/Area.php
setup/src/Magento/Setup/Module/Di/App/Task/Operation/Interception.php
setup/src/Magento/Setup/Module/Di/App/Task/Operation/InterceptionCache.php
we added cache logic to the method doOperation()
.
With some additional code, we’ve created a module from this files. You can download it here.
Installation.
Copy Eleanorsoft
folder to app/code/
.
Run setup:upgrade
.
Run setup:di:compile
.
After compilation, you should see a folder var/di_cache/
with 4 (or more) files. This is the actual cache. From now your compilation process will use these cached lists instead of scanning the whole filesystem.
During testing, we noticed 40% to 50% acceleration of the compilation process.
Note 1: these caches contain only core files. All custom modules will be scanned each time as usual.
Note 2: if you upgrade Magento 2, delete these files because core modules could change during the upgrade.
Related Post
Docker and Magento: Test and...
In this article, we will describe one of the ways to run Magento 2 on Docker. Docker is a...
- July 20, 2017
- By eleanors_admin
- Magento
Search for ALL words in...
By default Magento 2 QuickSearch feature searches for at least one word from the entered...
- August 2, 2017
- By eleanors_admin
- Magento
Install Magento 2 on Windows...
This article describes one of the ways to setup Magento 2 on Windows or Linux. This...
- August 26, 2017
- By eleanors_admin
- Magento
PayPal error: We can’t...
There is a bug with PayPal checkout on early versions of Magento 2. Users may see error...
- March 12, 2019
- By eleanors_admin
- Magento
Magento2 Mail Logger
This module helps to debug Magento2 emails saving them into a folder as seperate files....
- January 14, 2020
- By eleanors_admin
- Magento
EleanorSoft Became a...
On March 12th, we applied to Adobe Solution Partner Program (SPP) and were approved as a...
- March 15, 2020
- By eleanors_admin
- General