-
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
Avoid duplicate loading of configuration files #19585
Conversation
Hi @ajardin. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
@magento-engcom-team give me test instance |
Hi @ajardin. Thank you for your request. I'm working on Magento instance for you |
Hi @ajardin, here is your new Magento instance. |
@magento-engcom-team give me 2.3-develop instance |
Hi @ajardin. Thank you for your request. I'm working on Magento 2.3-develop instance for you |
Hi @ajardin, here is your Magento instance. |
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.
@ajardin thanks for the contribution. Please see the review notes. Also, please consider covering the changed functionality with tests
Hi @sivaschenko, thanks for taking time to review my pull request! About your suggestion on the test coverage, as I've only slightly rewrote an existing code covered by |
@ajardin a unit test which would check that files are accessed only once. An additional call to existing test can be added, I believe. |
@ajardin one more thing. Could you tell more which pages are slow and in which scenario? I grepped all the usages and this data seems to be cached properly, for example
|
Sorry @sivaschenko, I misunderstood your comments about the test suite... I've updated the existing test to check that the registered themes are loaded only once. @orlangur the scenario is described in the pull request description (log in to the back office and go to Content > Pages). All my application responds correctly except pages that contain grids. And by comparing with the Cache Management page, I discovered that the layouts configuration are loaded multiple times in I'm still not fully satisfied by the loading time, as we are still have to wait more than 20s, but I think it can be a first quick win. What's your opinion on that? |
@ajardin is |
Do you mean that using a property to store the result of |
Yep. Caching already occurs outside of builder class in most cases. |
I think there is still a misunderstanding. 😄 My current approach is to avoid duplicate calls to the filesystem within the same builder class by using a property which will save the result after the initial call. There is currently no usage of the Magento cache. For several reasons in fact:
There are two different things to address from my point of view. First the builder class can be improved to mitigate its impact on the overall performances because it's the most time consuming part. And then, we'll look at the grid class to check how to take advantage of Magento cache when it's possible. |
@ajardin by caching I mean storing in class property, but in another class, here was an example: #19585 (comment) I would like to avoid storing data in property in multiple places, so, please find out where calls to builder are still not cached. |
@orlangur I don't think the cache of client classes are related to this contribution. The |
@sivaschenko I don't see any scenario where this configuration is read more than once. Let's wait for the reply from contributor. There is no need to introduce any such internal caching unless really necessary because it is quite memory consuming. |
Sorry for the delay, but I thought the discussion was resolved after @sivaschenko's last comment. @orlangur, there is already a "caching" system through to a property in Here is another screenshot from my initial Blackfire profile to illustrate this behavior. |
@ajardin thanks, so there are actually two calls made in different classes within same scenario. What do you think about removing unneeded internal caching of options so that we consume less memory? |
Hi @orlangur, thank you for the review. |
@orlangur @ajardin removing protected properties is backward incompatible change. Such changes can break environments where these classes are extended and properties used. |
@sivaschenko good point, thanks. |
app/code/Magento/Catalog/Model/Product/Attribute/Source/Layout.php
Outdated
Show resolved
Hide resolved
Hi @orlangur, do you see something else to change? |
Hi @orlangur, thank you for the review. |
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 @ajardin , thank you for your updates. Can you please keep the implementation of client methods as they are until the deprecated property will be removed.
*/ | ||
public function getAllOptions() | ||
{ | ||
if (!$this->_options) { |
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.
It looks a bit wired to set a value to the property and avoid using it. I think existing method body is more clear and avoids additional options processing.
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.
There is no any additional "option processing".
It looks a bit wired to set a value to the property and avoid using it
This is what current recommendation says. It would be much better to just remove property as probability of BC break is negligible, but if you insist on keeping it deprecated - let's just keep it prepared for removal.
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 guys, are you expecting something from me?
Because I made what was the most logical thing from my point of view:
- deprecate the property
- keep assigning a value to the deprecated property
- remove internal usages of the property to prepare its removal
But I'm not sure to understand exactly what you want right now... 😄
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.
@ajardin yeah, everything is fine from my point of view. Remaining part is to convince Sergey, no code changes required until we agree upon them.
Hi @orlangur, thank you for the review. |
Hi @orlangur and @sivaschenko, (Happy New Year by the way) |
Hi @ajardin , Happy New Year! This pull request is currently going throug internal verification process and is on it's way to mainline. |
Hi @sivaschenko, thanks for the confirmation! |
Hi @ajardin sorry, and thanks for notification, the label was removed. |
Hi @ajardin, thank you for your contribution! |
Hi @ajardin. Thank you for your contribution. |
Description (*)
While I was investigating why some pages in back-office are extremely slow on my local environment, I found out that we are currently loading multiple times all
layouts.xml
files in the\Magento\Theme\Model\PageLayout\Config\Builder
class.Through this change, I propose to only load them one time by adding a new property to store the result and reuse it for the next calls. There is no structural change and the loading time is reduced by almost 40% on my local environment, as you can see with the screenshots from Blackfire below.
Previously:
![Blackfire screenshot](https://camo.githubusercontent.com/a4a6f4756e721a9df75d17b7eed1dad23388a135d2b6aa58690fa7ce8ae7a485/68747470733a2f2f6475617732366a6568716434722e636c6f756466726f6e742e6e65742f6974656d732f30343078336332723355335632433172326e32552f676574436f6e66696746696c65732d6265666f72652e706e67)
Now:
![Blackfire screenshot](https://camo.githubusercontent.com/682a8711f24fdcc912cfe8ce7048b93e44f9eae7b9c8a543aa3b49992c34faeb/68747470733a2f2f6475617732366a6568716434722e636c6f756466726f6e742e6e65742f6974656d732f305a304e316c316631553052306333733067316a2f25354232316163316263363162346663613835353335666431333031646464373664302535445f676574436f6e66696746696c65732d61667465722e706e67)
Comparison:
![Blackfire screenshot](https://camo.githubusercontent.com/26dd1c8f9f22f398f3fe20c44fc9871db366eb477be4b921a77ced337a9ea95e/68747470733a2f2f6475617732366a6568716434722e636c6f756466726f6e742e6e65742f6974656d732f3349304832593059303133563033326b337532502f25354262373634633136653237313836303830366336646566343666356235343263632535445f676574436f6e66696746696c65732d636f6d70617269736f6e2e706e67)
Manual testing scenarios (*)
Please note that I'm using Docker for Mac with this environment, and the application is in
developer
mode with all caches activated. The latest version is used for both Docker and Magento.Contribution checklist (*)