Skip to content

Greatly improve performance by caching subsequent glob calls #33998

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

Merged

Conversation

thlassche
Copy link
Contributor

@thlassche thlassche commented Sep 6, 2021

Description (*)

This pull request introduces an in-memory cache for glob system calls. On systems where file I/O is slow (for example Docker for Mac), glob system calls can be quite slow. This pull requests caches the same glob calls and returns a cached result if possible. In my testing this reduced the glob calls on the category listings from ~8K to ~1.6K.

Blackfire comparison:

Screenshot 2021-09-06 at 09 51 21

Related Pull Requests

None

Fixed Issues (if relevant)

None

  1. Fixes magento/magento2#<issue_number>

Manual testing scenarios (*)

  1. Profile any page before this diff is applied
  2. Apply diff and reprofile
  3. See a reduction in glob() calls

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Resolved issues:

  1. resolves [Issue] Greatly improve performance by caching subsequent glob calls #34024: Greatly improve performance by caching subsequent glob calls

Resolved issues:

  1. resolves [Issue] Greatly improve performance by caching subsequent glob calls #34025: Greatly improve performance by caching subsequent glob calls

@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2021

Hi @thlassche, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@thlassche thlassche reopened this Sep 6, 2021
@m2-assistant
Copy link

m2-assistant bot commented Sep 6, 2021

Hi @thlassche. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

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.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 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

@ihor-sviziev
Copy link
Contributor

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@thlassche
Copy link
Contributor Author

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@andrewbess andrewbess self-assigned this Sep 6, 2021
@ihor-sviziev ihor-sviziev added Area: Perf/Frontend All tickets related with improving frontend performance. Severity: S1 Affects critical data or functionality and forces users to employ a workaround. Area: Performance labels Sep 6, 2021
@ihor-sviziev ihor-sviziev changed the title Greatly improve performance on dockerized Magento instances (mainly on mac) by caching subsequent glob calls Greatly improve performance by caching subsequent glob calls Sep 6, 2021
@ihor-sviziev
Copy link
Contributor

It might significantly improve performance not only on dockerized environments but also on the ec2 instances or any server using network file storage as magento storage.

@magento-engcom-team
Copy link
Contributor

Hi @andrewbess, thank you for the review.
ENGCOM-9214 has been created to process this Pull Request
✳️ @andrewbess, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@magento-engcom-team
Copy link
Contributor

Hi @ihor-sviziev, thank you for the review.
ENGCOM-9214 has been created to process this Pull Request
✳️ @ihor-sviziev, could you please add one of the following labels to the Pull Request?

Label Description
Auto-Tests: Covered All changes in Pull Request is covered by auto-tests
Auto-Tests: Not Covered Changes in Pull Request requires coverage by auto-tests
Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests

@ihor-sviziev ihor-sviziev added the Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests label Sep 6, 2021
@ihor-sviziev
Copy link
Contributor

I think we don't need to cover it with any test as it will be not so easy.

@engcom-Hotel
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@onlinebizsoft
Copy link

It might significantly improve performance not only on dockerized environments but also on the ec2 instances or any server using network file storage as magento storage.

What do you mean by "magento storage"? You mean "media storage"? @ihor-sviziev

@ihor-sviziev
Copy link
Contributor

@onlinebizsoft, I think it's not only media folder, but also where magento code is located.

Copy link
Contributor

@engcom-Hotel engcom-Hotel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @thlassche,

Some tests are failing for e.g. Functional Tests B2B, Functional Tests CE, Functional Tests EE. Please look into this.

@ihor-sviziev
Copy link
Contributor

@engcom-Hotel, the service that responsible for the currency API doesn't work. Here is confirmation: #34021 (comment)

@onlinebizsoft
Copy link

@onlinebizsoft, I think it's not only media folder, but also where magento code is located.

Interesting! Im not sure how glob is used and called in Magento. I thought Magento files would be loaded in OPcache memory already

@engcom-Hotel
Copy link
Contributor

@engcom-Hotel, the service that responsible for the currency API doesn't work. Here is confirmation: #34021 (comment)

Thanks for the clarification @ihor-sviziev

@engcom-Hotel
Copy link
Contributor

✔️ QA Passed

Hello @thlassche,

Thanks for the contribution!

Preconditions
Magento 2.4-develop branch

Manual testing scenario

  1. Run profiler on Magento 2.4-develop with sample data installed.
  2. Run profiler on this PR fix with sample data installed.
  3. Compare results.

image

@onlinebizsoft
Copy link

✔️ QA Passed

Hello @thlassche,

Thanks for the contribution!

Preconditions
Magento 2.4-develop branch

Manual testing scenario

1. Run profiler on Magento 2.4-develop with sample data installed.

2. Run profiler on this PR fix with sample data installed.

3. Compare results.

image

Just reduce few ms?!!

@thlassche
Copy link
Contributor Author

✔️ QA Passed

Hello @thlassche,

Thanks for the contribution!

Preconditions

Magento 2.4-develop branch

Manual testing scenario

1. Run profiler on Magento 2.4-develop with sample data installed.
2. Run profiler on this PR fix with sample data installed.
3. Compare results.

image

Just reduce few ms?!!

It depends a lot on what is currently in the cache and what is not. The first load of uncached pages will benefit way more.

@ihor-sviziev
Copy link
Contributor

@magento run Functional Tests B2B, Functional Tests CE, Functional Tests EE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@Den4ik
Copy link
Contributor

Den4ik commented Sep 24, 2021

@magento run all test

@magento-automated-testing
Copy link

Failed to run the builds. Please try to re-run them later.

@Den4ik
Copy link
Contributor

Den4ik commented Sep 24, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-engcom-team magento-engcom-team merged commit eae78dc into magento:2.4-develop Nov 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Perf/Frontend All tickets related with improving frontend performance. Area: Performance Auto-Tests: Not Required Changes in Pull Request does not require coverage by auto-tests Award: category of expertise Component: Filesystem Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: accept Release Line: 2.4 Severity: S1 Affects critical data or functionality and forces users to employ a workaround.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Issue] Greatly improve performance by caching subsequent glob calls [Issue] Greatly improve performance by caching subsequent glob calls
8 participants