Skip to content
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: cache missing XBlock mappings in load_class #813

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ormsbee
Copy link
Contributor

@ormsbee ormsbee commented Jan 19, 2025

Checking the entrypoints for the XBlock class we want for a given tag name is relatively expensive. We mitigate this by caching the mapping of tags to classes in Plugin.load_class(). But before this commit, we weren't caching failed lookups, i.e. the situation where there is no XBlock that maps to a given tag. This meant that if a course had many instances of a type of XBlock that is not installed on the given server, we would be constantly scanning entrypoints to look for our non-existent XBlock subclass. This really slows down things like the Studio course outline page.

The fix here is to store failed lookups as None values in the PLUGIN_CACHE.

Checking the entrypoints for the XBlock class we want for a given tag
name is relatively expensive. We mitigate this by caching the mapping
of tags to classes in Plugin.load_class(). But before this commit, we
weren't caching failed lookups, i.e. the situation where there is no
XBlock that maps to a given tag. This meant that if a course had many
instances of a type of XBlock that is not installed on the given
server, we would be constantly scanning entrypoints to look for our
non-existent XBlock subclass. This really slows down things like the
Studio course outline page.

The fix here is to store failed lookups as None values in the
PLUGIN_CACHE.
@ormsbee
Copy link
Contributor Author

ormsbee commented Jan 19, 2025

Fixes #811

FYI @openedx/interest-performance

@ormsbee ormsbee added the performance Relates to improving latency/throughput or reducing resource usage label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Relates to improving latency/throughput or reducing resource usage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant