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.
we added cache logic to the method
With some additional code, we’ve created a module from this files. You can download it here.
Eleanorsoft folder to
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.