Merge pull request #5212 from cpennington/split/import-export-performance
Improve performance of split-mongo import/export performance
This commit is contained in:
@@ -326,19 +326,29 @@ class TestTOC(ModuleStoreTestCase):
|
||||
self.request = factory.get(chapter_url)
|
||||
self.request.user = UserFactory()
|
||||
self.modulestore = self.store._get_modulestore_for_courseid(self.course_key)
|
||||
with check_mongo_calls(num_finds, num_sends):
|
||||
self.toy_course = self.store.get_course(self.toy_loc, depth=2)
|
||||
self.field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
|
||||
self.toy_loc, self.request.user, self.toy_course, depth=2
|
||||
)
|
||||
with self.modulestore.bulk_operations(self.course_key):
|
||||
with check_mongo_calls(num_finds, num_sends):
|
||||
self.toy_course = self.store.get_course(self.toy_loc, depth=2)
|
||||
self.field_data_cache = FieldDataCache.cache_for_descriptor_descendents(
|
||||
self.toy_loc, self.request.user, self.toy_course, depth=2
|
||||
)
|
||||
|
||||
# TODO: LMS-11220: Document why split find count is 9
|
||||
# TODO: LMS-11220: Document why mongo find count is 4
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0), (ModuleStoreEnum.Type.split, 9, 0))
|
||||
# Mongo makes 3 queries to load the course to depth 2:
|
||||
# - 1 for the course
|
||||
# - 1 for its children
|
||||
# - 1 for its grandchildren
|
||||
# Split makes 6 queries to load the course to depth 2:
|
||||
# - load the structure
|
||||
# - load 5 definitions
|
||||
# Split makes 2 queries to render the toc:
|
||||
# - it loads the active version at the start of the bulk operation
|
||||
# - it loads the course definition for inheritance, because it's outside
|
||||
# the bulk-operation marker that loaded the course descriptor
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0, 0), (ModuleStoreEnum.Type.split, 6, 0, 2))
|
||||
@ddt.unpack
|
||||
def test_toc_toy_from_chapter(self, default_ms, num_finds, num_sends):
|
||||
def test_toc_toy_from_chapter(self, default_ms, setup_finds, setup_sends, toc_finds):
|
||||
with self.store.default_store(default_ms):
|
||||
self.setup_modulestore(default_ms, num_finds, num_sends)
|
||||
self.setup_modulestore(default_ms, setup_finds, setup_sends)
|
||||
expected = ([{'active': True, 'sections':
|
||||
[{'url_name': 'Toy_Videos', 'display_name': u'Toy Videos', 'graded': True,
|
||||
'format': u'Lecture Sequence', 'due': None, 'active': False},
|
||||
@@ -354,20 +364,29 @@ class TestTOC(ModuleStoreTestCase):
|
||||
'format': '', 'due': None, 'active': False}],
|
||||
'url_name': 'secret:magic', 'display_name': 'secret:magic'}])
|
||||
|
||||
with check_mongo_calls(0, 0):
|
||||
with check_mongo_calls(toc_finds, 0):
|
||||
actual = render.toc_for_course(
|
||||
self.request.user, self.request, self.toy_course, self.chapter, None, self.field_data_cache
|
||||
)
|
||||
for toc_section in expected:
|
||||
self.assertIn(toc_section, actual)
|
||||
|
||||
# TODO: LMS-11220: Document why split find count is 9
|
||||
# TODO: LMS-11220: Document why mongo find count is 4
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0), (ModuleStoreEnum.Type.split, 9, 0))
|
||||
# Mongo makes 3 queries to load the course to depth 2:
|
||||
# - 1 for the course
|
||||
# - 1 for its children
|
||||
# - 1 for its grandchildren
|
||||
# Split makes 6 queries to load the course to depth 2:
|
||||
# - load the structure
|
||||
# - load 5 definitions
|
||||
# Split makes 2 queries to render the toc:
|
||||
# - it loads the active version at the start of the bulk operation
|
||||
# - it loads the course definition for inheritance, because it's outside
|
||||
# the bulk-operation marker that loaded the course descriptor
|
||||
@ddt.data((ModuleStoreEnum.Type.mongo, 3, 0, 0), (ModuleStoreEnum.Type.split, 6, 0, 2))
|
||||
@ddt.unpack
|
||||
def test_toc_toy_from_section(self, default_ms, num_finds, num_sends):
|
||||
def test_toc_toy_from_section(self, default_ms, setup_finds, setup_sends, toc_finds):
|
||||
with self.store.default_store(default_ms):
|
||||
self.setup_modulestore(default_ms, num_finds, num_sends)
|
||||
self.setup_modulestore(default_ms, setup_finds, setup_sends)
|
||||
section = 'Welcome'
|
||||
expected = ([{'active': True, 'sections':
|
||||
[{'url_name': 'Toy_Videos', 'display_name': u'Toy Videos', 'graded': True,
|
||||
@@ -384,7 +403,8 @@ class TestTOC(ModuleStoreTestCase):
|
||||
'format': '', 'due': None, 'active': False}],
|
||||
'url_name': 'secret:magic', 'display_name': 'secret:magic'}])
|
||||
|
||||
actual = render.toc_for_course(self.request.user, self.request, self.toy_course, self.chapter, section, self.field_data_cache)
|
||||
with check_mongo_calls(toc_finds, 0):
|
||||
actual = render.toc_for_course(self.request.user, self.request, self.toy_course, self.chapter, section, self.field_data_cache)
|
||||
for toc_section in expected:
|
||||
self.assertIn(toc_section, actual)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user