Skip to content

Conversation

@davestgermain
Copy link
Contributor

@davestgermain davestgermain commented Jan 31, 2020

This adds some caching to reduce queries around rendering units/verticals (particularly when viewed from the new courseware MFE). On devstack, I measured between 10-20% improvement in response times.

Further improvements can be made around FBE/marketing injections. Currently, most of the time is spent outside of the xblock runtime.

TNL-7057

@davestgermain davestgermain requested a review from a team January 31, 2020 15:56
@davestgermain davestgermain force-pushed the dcs/perf-vertical branch 3 times, most recently from f473524 to 9a32506 Compare February 3, 2020 15:38
@davestgermain davestgermain requested a review from a team February 3, 2020 15:38
@davestgermain davestgermain requested a review from a team as a code owner February 3, 2020 15:38
@davestgermain davestgermain requested a review from a team February 3, 2020 15:38
@davestgermain davestgermain requested a review from a team as a code owner February 3, 2020 15:38
@davestgermain davestgermain force-pushed the dcs/perf-vertical branch 6 times, most recently from 3bd7c2b to a4ad703 Compare February 4, 2020 15:28
@davestgermain
Copy link
Contributor Author

jenkins run python
jenkins run bokchoy

@davestgermain davestgermain changed the title WIP tweaks to improve vertical performance Improve Vertical Performance Feb 5, 2020
@davestgermain davestgermain requested a review from ormsbee February 6, 2020 14:17
Invalidate all keys tracked by the manager.
"""
for key in self.keys:
TieredCache.delete_all_tiers(key)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you please change this to use the request cache instead of the tiered cached? Setting things in memcached across processes doesn't buy that much performance, but it could cause weird bugs because memcached lives outside the transaction lifetime of the database. So for instance, if we do a save on a model within a transaction, and that transaction later gets rolled back, using the tiered cache like this would have already done a set in memcached with that model value. Then that bad/rolled-back value would be alive in memcached for another process that runs.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, that way we don't have to worry about what happens when we serialize into memcache an older version of a model that just had a column added to it, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made this invalidation class in order to cache the XBlockConfiguration queryset, which rarely changes (and only through the deployment process or django admin, right?). I don't think there's much win by storing it in the request, but it seems appropriate to keep it in memcached.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah. I was more worried about the long term if this started being used for things like enrollments. I agree this is safe to do for something like config models.

But if that's the use case, then I think we were hitting at the same problem from different sides. :-(

openedx/django-config-models#55

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, that will be a good change. When will it land? Can I help?

But it won't solve this particular problem -- the xblock config is accessed like XBlockConfiguration.objects.current_set().filter(deprecated=True), which would bypass your caching. We could add similar caching to current_set(), or I could keep this for now, with a big TODO to remove it once there's caching in config models?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's close to merge, I just dropped it when we were getting close to the LabXchange launch and didn't pick it back up again. Let me do that today, as part of this story. I think I just need some minor fixes at this point.

I did think it addressed the XBlockConfiguration issue (at least most of them), because that was the major thing I was trying to eliminate when I was doing this optimization. But we should test it out in any event. Let me get that merged, then we can measure. I'll fix up that PR right now and tag you on review.

Copy link
Contributor

@ormsbee ormsbee left a comment

Choose a reason for hiding this comment

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

Just a request to use the request cache instead of tiered cache.

@davestgermain davestgermain force-pushed the dcs/perf-vertical branch 2 times, most recently from 8fb88ce to 3729fd4 Compare February 10, 2020 16:51
@davestgermain davestgermain force-pushed the dcs/perf-vertical branch 2 times, most recently from f50ed25 to c34706e Compare February 19, 2020 15:37
Copy link
Contributor

@ormsbee ormsbee left a comment

Choose a reason for hiding this comment

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

I have concerns about possible behavior changes with edxnotes. If there's an explanation for that or that part of it is taken out, I'm good to go with this PR. (If it stays, please include a comment in the PR about why the shift was made and why it's safe to do so.)

Thank you.

@davestgermain
Copy link
Contributor Author

jenkins run a11y

@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@davestgermain davestgermain merged commit 00f5beb into master Feb 20, 2020
@davestgermain davestgermain deleted the dcs/perf-vertical branch February 20, 2020 17:30
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/deploy_to_stage

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR may have caused e2e tests to fail on Stage. If you're a member of the edX org, please visit #e2e-troubleshooting on Slack to help diagnose the cause of these failures. Otherwise, it is the reviewer's responsibility. E2E tests have failed. https://gocd.tools.edx.org/go/tab/pipeline/history/deploy_to_stage

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants