-
Notifications
You must be signed in to change notification settings - Fork 84
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
Use APCu as Composer level 2 optimisation strategy #795
base: develop
Are you sure you want to change the base?
Conversation
Static Analysis & Code Style Results❌ One or more static analysis or code style checks have failed. PHP Codesniffer Output
PHP Mess Detector Output
PHPStan Output
This comment was generated by Jenkins job ece-tools/static build 22. |
Unit & Integration Test Results❌ One or more unit or integration tests have failed. Unit Test Output
Integration Test Output
This comment was generated by Jenkins job ece-tools/unit build 23. |
Functional Acceptance Test Results❌ One or more functional acceptance tests have failed. PHP 7.1❓ No scenario results found PHP 7.2❓ No scenario results found PHP 7.3❓ No scenario results found PHP 7.4❓ No scenario results found Output for failed tests is below. If many tests have failed only the first 5 will be included. If you need additional information please reach out to the Magento Cloud team for more details. This comment was generated by Jenkins job ece-tools/functional build 37. |
@gabrieldagama How can we get the PHP extension APCu installed automatically on Magento Cloud which is a requirement for this change? |
Does this provide any substantive benefits over Composer Level 1 + Opcache? |
Yes. Opcache is an important but distinct optimisation. Opcache will cache the compiled contents of a file in memory. Level 2 composer cache will cache which file-system path contains a class. Without a level 2 cache, the autoloader will scan several file-system locations until it finds a suitably named file for the corresponding class. When a file is found, it will be read & compiled (or pulled from opcache if enabled & available) and the class evaluated for use as normal. With a level 2 cache, the autoloader will read the file location from this cache, rather than having to test every file-system location in sequence until a match is found. File-system access can be expensive. Let's talk through an example. Consider a scenario with an include path of "a, b, c, d, e, f, g" and a class existing in path "g." Without a level 2 cache, each time the class is required, the autoloader will:
With a primed* level 2 cache, each time the class is required, the autoloader will:
Hopefully this helps show why both optimisations are useful. |
@fredden With |
This is the code being referring to: Yes, the level 1 / class map is always used first, and will often be effective for finding classes. The level 2 cache is useful for classes that did not exist at the time the autoloader was dumped. For example, when running For reference, I've done a quick check this evening on a Magento v2.4.2-p1 website. When running See also https://getcomposer.org/doc/articles/autoloader-optimization.md |
According to the Composer documentation the APCu optimization can be enabled in the
should enable APCu caching in Composer and makes this patch obsolete, correct? |
@phoenix-bjoern the required extension is not yet installed / available by default on Adobe Cloud. |
@fredden I've created a ticket and referenced the DevDocs where Adobe explicitly recommends the installation of APCu (https://experienceleague.adobe.com/docs/commerce-operations/implementation-playbook/infrastructure/performance/recommendations.html?lang=en#php-fpm-settings). The extension got installed by the Adobe support team. Maybe just try it again ;-) |
Description
Composer offers two levels of autoloader optimisation. Currently level 1 is enabled; this pull request enables level 2 optimisations using the safest-available option. https://getcomposer.org/doc/articles/autoloader-optimization.md
Fixed Issues (if relevant)
None
Manual testing scenarios
Release notes
Use APCu as Composer level 2 optimisation strategy. This is a performance improvement that comes with a dependency on the APCu extension. This extension is installed on Magento Cloud automatically.
Associated documentation updates
Contribution checklist