-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
perf: add lru_cache to improve performance with multiple themes #31090
perf: add lru_cache to improve performance with multiple themes #31090
Conversation
Thanks for the pull request, @Alec4r! Please note that it may take us up to several weeks or months to complete a review and merge your PR. Feel free to add as much of the following information to the ticket as you can:
All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here. Please let us know once your PR is ready for our review and all tests are green. |
FYI @openedx/perf-interest: This is a great perf win, but the bigger takeaway here is that the switch to docker-based deployment looks like it's causing disk I/O to become much more expensive, meaning that we could see performance regressions in a bunch of places that we haven't touched in a long time. But enough sober talk. Look at the sweet numbers! Before:
After:
|
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.
The code looks fine (after tests pass again), but a few requests on the commit message:
- Please use
perf:
instead offeat:
for this. (For the full list of possible types, please see the "Type" section of OEP-51. - Please take the context you give in your PR description and add it to your commit message.
- You might want to also mention that it's the file I/O that's causing issues, that this came up when running in Docker, and that it saves thousands of calls to listdir (?) when running with a handful of themes.
Having external links is fine, but please add enough context to your commit message so that it's clear why this was done even if the link breaks later. Ten years from now, we might no longer be using the current forums, or even GitHub. But the commit message will live on.
BTW, I think the tests should be able to clear the LRU cache with calls like |
364c111
to
d3d548a
Compare
d3d548a
to
74cc363
Compare
I can't approve and run your test. Is there something wrong with the runner? |
GHA is reporting an error: https://github.com/openedx/edx-platform/actions/runs/3190974009 It says I think this is an error on master, I'll take a look. |
Yup, the error is from master. Once this fix merges, you can rebase and then tests should run. |
Merged the CI fix, @Alec4r you should be good to rebase now. |
e4fd059
to
80ece3e
Compare
677f75e
to
b7be69b
Compare
These changes should improve the performance caused by the file I/O when it's running in docker, using lru_cache to save thousands of calls to listdir when running with a handful of themes defined in COMPREHENSIVE_THEME_DIRS.
b7be69b
to
1a1e4ad
Compare
Not sure why I had to authorize the workflows a second time, but I'll merge once tests pass. |
@ormsbee: not sure either. But each time a first-time contributor opens a PR, someone with permissions needs to approve the workflow each time a new commit is pushed. Not sure what the conditions are for this to happen, but it has happened to me a couple of times. |
@ormsbee the tests are passing, we can continue with the merge? |
@Alec4r 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future. |
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
EdX Release Notice: This PR has been deployed to the production environment. |
EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production. |
EdX Release Notice: This PR has been deployed to the production environment. |
1 similar comment
EdX Release Notice: This PR has been deployed to the production environment. |
@Alec4r: Please add a note about this to the Olive release notes page under the Operational section. Anybody running a Docker-based deployment with theming will likely be interested in this. |
These changes should improve the performance when there are plenty of themes defined in COMPREHENSIVE_THEME_DIRS, using lru_cache to reduce the number of calls to the method is_theme_dir.
We have a bad response time due to the file I/O when it's running in docker the more themes you add to your platform the more slow answer you will have.
We can evidence this in these tests:
Test without comprehensive theming (0 Themes)
running (10m09.6s), 00/28 VUs, 602 complete and 0 interrupted iterations http_req_duration..............: avg=553.57ms min=107.08ms med=492.97ms max=3.98s p(90)=1.02s p(95)=1.24s
Test with indigo (1 Theme)
running (10m15.3s), 00/28 VUs, 523 complete and 0 interrupted iterations http_req_duration..............: avg=1.24s min=132.26ms med=1.23s max=2.95s p(90)=2s p(95)=2.17s
Test with multiple themes (5 Themes)
running (10m12.7s), 00/28 VUs, 313 complete and 3 interrupted iterations http_req_duration..............: avg=4.56s min=111.86ms med=5.25s max=7.57s p(90)=6.25s p(95)=6.5s
Finally, we can see the improvement with the changes in this PR (5 Themes)
running (10m06.6s), 00/28 VUs, 592 complete and 0 interrupted iterations http_req_duration..............: avg=633.36ms min=101.13ms med=606.9ms max=2.15s p(90)=1.13s p(95)=1.27s
For a thorough description of the issue, performance tests & solution design, you could refer to
ISSUE: Comprehensive theming performance
We may wish to backport all of these changes to Nutmeg