-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
[Performance] Implement command loader to reduce initialization time of Magento CLI #29355
base: 2.4-develop
Are you sure you want to change the base?
[Performance] Implement command loader to reduce initialization time of Magento CLI #29355
Conversation
Hi @mattwellss. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just sharing my thoughts seeing your work :)
lib/internal/Magento/Framework/App/Test/Unit/Console/CommandLoader/AggregateTest.php
Show resolved
Hide resolved
lib/internal/Magento/Framework/App/Test/Unit/Console/CommandLoader/AggregateTest.php
Outdated
Show resolved
Hide resolved
lib/internal/Magento/Framework/App/Test/Unit/Console/CommandLoader/AggregateTest.php
Outdated
Show resolved
Hide resolved
lib/internal/Magento/Framework/Console/CommandLoader/Aggregate.php
Outdated
Show resolved
Hide resolved
lib/internal/Magento/Framework/App/Test/Unit/Console/CommandLoader/AggregateTest.php
Outdated
Show resolved
Hide resolved
lib/internal/Magento/Framework/App/Test/Unit/Console/CommandLoader/AggregateTest.php
Outdated
Show resolved
Hide resolved
Hi @mattwellss, thank you for your contribution! |
Hi @mattwellss. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. |
@magento run all tests |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mattwellss, thanks for the pull request, it looks great! Please follow some small comments on it.
I can definitely see the benefit of using CommandLoader
over CommandList
, by deferring the creation of the command objects just when we actually call it. From the performance perspective, I'm not having that much of a difference, on my tests, I'm clearing the cache on both runs to make sure the performance is actually increased.
So when changing branches I'm actually running:
bin/magento cache:clean && time bin/magento setup:install --help
Running on 2.4-develop:
bin/magento setup:install --help 13.61s user 0.85s system 91% cpu 15.854 total
Running on implement-command-loader:
bin/magento setup:install --help 13.38s user 0.79s system 92% cpu 15.309 total
Could you confirm if the performance increase is similar to what I'm getting here?
Let me know your thoughts! Thanks!
@gabrieldagama, thanks for the review. I appreciate it! Regarding performance:
Some results: On 2.4-develop:
On implement-command-loader:
Let me know if you see similar percentage improvement (the command loader version finishes in about 85% of the time of the base branch). On my installation of Magento, there are 57 commands added via the |
Thanks for the detailed reply @mattwellss! I understand your point, I will do a further investigation here, but on my environment, with warmed cache, there is not much difference in performance. Regards the other using Thanks! |
@magento run all tests |
@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, Integration Tests, Semantic Version Checker, Static Tests, Unit Tests |
@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE, Integration Tests, Unit Tests |
@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE |
Hi @mattwellss and @ihor-sviziev, Kindly look into this comment and please provide you input so that we can proceed the PR further. Thank you! |
There is no way this output is accurate. Probably your computer was working hard on something else while you tested it, which caused the result to take a lot longer then it should? Best is probably to run your tests up to 5 or 10 different times, drop the highest and lowest value and make an average of the other runs. |
Hi @hostep, As you see above comment threads, many times we have tested this and conveyed the same here. This above result also posted after many execution. Thank you! |
@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE |
1 similar comment
@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE |
Failures of Functional CE, B2B and EE are known open issues related to Page builder repo. Hence moving this to Merge in Progress. Functional B2B: Functional CE: Functional EE: Known JIRA: |
Moving this PR to extended testing since the copyright tag has not been updated in the mentioned files. |
@magento run Static Tests |
@magento run all tests |
Description (*)
This change reduces initialization time of the Magento CLI app by allowing deferred initialization of commands until they're needed.
\Magento\Setup\Console\CommandLoader
, a replacement forMagento_Setup
'sCommandList
\Magento\Framework\Console\CommandLoader
, an alternative means of adding commands outside theMagento\Setup
namespace\Magento\Framework\Console\CommandLoader\Aggregate
, an aggregate command loader, necessary because a Symfony CLI app can only have one Command Loader.Related Pull Requests
None
Fixed Issues (if relevant)
Manual testing scenarios (*)
time
; for exmaple:time ./bin/magento setup:install --help
and note how long it takesQuestions or comments
\Magento\Framework\ObjectManager\TMap
seems feasible)setup:install
andsetup:config:set
as the two commands causing the most slowdown, so I focused first on migrating the commands inMagento_setup
. I'm happy to migrate more commands to use the Command Loader, but it seems unnecessary from a performance perspective.Magento\Setup\Console\CommandList
be removed entirely, or just have itsgetCommandsClasses()
method updated to return an empty array? The latter would preserve BC, in the case that people have extended the class with their own commands.Contribution checklist (*)