-
Bug
-
Resolution: Duplicate
-
Critical
-
None
-
2.6.4, 3.3.2, 3.5.2
-
MOODLE_26_STABLE, MOODLE_33_STABLE, MOODLE_35_STABLE
Analysis
Environment
We are using Moodle 2.6.4+ containing about 3200 course categories in one single instance and Moodle File cache.
For profiling reasons we've installed XHProf.
Problem Reproduction
- login as user with course categories editing rights
- go to a editable course category
- click on "Edit this category"
- do any changes and click on "Save changes"
What we know
- There are several caching frameworks
- File cache
- memcache (We can't use this in our environment)
- memcaches (We also can't use this in our environment)
- MongoDB
- There are several caching scopes
- application
- session
- static
- There is a course categories tree cache (in the application cache)
- The coursecattree is needed for building the navigation e.g. on the "Course and category management" page
- There are several invalidation-events that trigger the purging of the cache
- There is an event called "changesincoursecat" that is purging the whole application cache
Problem Analysis
When editing a course category the coursecattree-cache will be purged and the user is forwarded to the "Course and category management" page, where parts of the coursecattree-cache are needed. Because of the reason that the coursecattree-cache is invalid at this moment the tree has to be rebuilt. On a local environment this step takes about 15 seconds. At this step about 6000 cache-files are written (2.5 ms per file).
The coursecattree-cache is an application cache. During the regeneration of this application cache, the cache is locked for other users until the cache is generated. This leads to long waiting times. The productive environment shows waiting times up to 2 minutes.
We checked the problem with a small Moodle installation and counldn't reproduce the problem. Therefore the problem must be in coincidence with the large number of course categories.
We also tested with Moodle 2.6.5+ and 2.7.2+. Same problems.
Profiling and Call Graphs
- course/management.php with purged cache >> 2014-11-05_withPurgedCache.mpr
- course/management.php with caching >> 2014-11-05_withCaching.mpr
As you can see the Call Graph with purged Cache shows a total time of 25838.202 ms where writing the files consumes 12607.197 ms (= 5940 files (= 2 x 2970 course categories)).
Related Issues
We already had a look at some related Moodle issues. No success...
- https://tracker.moodle.org/browse/MDL-39443
- https://tracker.moodle.org/browse/MDL-34320
- https://tracker.moodle.org/browse/MDL-35179
- https://tracker.moodle.org/browse/MDL-41114
- https://tracker.moodle.org/browse/MDL-41127
- https://tracker.moodle.org/browse/MDL-40280
- https://tracker.moodle.org/browse/MDL-31830
Hopefully someone can help.