Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-67681

Improve course category tree cache performance by storing against single key instead of multiple

XMLWordPrintable

    • MOODLE_38_STABLE
    • MOODLE_39_STABLE
    • MDL-67681_master
    • Hide
      1. Ensure your test site has "Performance Info" enabled in Site Administration > Developer > Debugging settings
      2. Ensure your test site has the coursecattree cache set to use the default application file cache in Site Administration > Plugins > Caches > Configuration
      3. Go to Site Administration > Courses > Manage courses and categories
      4. Ensure you have several course categories
      5. Change the order of a course category by pressing the up or down arrow next to its entry in the list (this will invalidate the cache).
      6. Reload the page, and check the performance info for core/coursecattree in the footer.
        • EXPECTED: The cachestore_file shows 0 hits, 3 misses and 2 sets (the whole tree is set in 1 key, and the last invalidation timestamp in a second.
        • BEFORE FIX: The cachestore_file shows 0 hits, 3 misses and 2n + 4 sets where n is the number of categories.
      7. Reload the page again, and check the performance info for core/coursecattree in the footer.
        • EXPECTED: The cachestore_file shows 2 hits, 0 misses and 0 sets.
        • BEFORE FIX: The cachestore_file shows n + 1 hits, 0 misses and 0 sets where n is the number of categories,
      8. Purge all caches and reload the course and category management page again.
      9. In your file manager, look in $CFG->dataroot/cache/cachestore_file/default_application/core_coursecattree.
        • EXPECTED: There should be 2 directories, each containing 1 file.
        • BEFORE FIX: There should be 2n + 4 files across several directories.

       

      Show
      Ensure your test site has "Performance Info" enabled in Site Administration > Developer > Debugging settings Ensure your test site has the coursecattree cache set to use the default application file cache in Site Administration > Plugins > Caches > Configuration Go to Site Administration > Courses > Manage courses and categories Ensure you have several course categories Change the order of a course category by pressing the up or down arrow next to its entry in the list (this will invalidate the cache). Reload the page, and check the performance info for core/coursecattree in the footer. EXPECTED : The cachestore_file shows 0 hits, 3 misses and 2 sets (the whole tree is set in 1 key, and the last invalidation timestamp in a second. BEFORE FIX: The cachestore_file shows 0 hits, 3 misses and 2n + 4 sets where n is the number of categories. Reload the page again, and check the performance info for core/coursecattree in the footer. EXPECTED : The cachestore_file shows 2 hits, 0 misses and 0 sets. BEFORE FIX: The cachestore_file shows n + 1 hits, 0 misses and 0 sets where n is the number of categories, Purge all caches and reload the course and category management page again. In your file manager, look in $CFG->dataroot/cache/cachestore_file/default_application/core_coursecattree. EXPECTED : There should be 2 directories, each containing 1 file. BEFORE FIX: There should be 2n + 4 files across several directories.  

      Related to MDL-67674,

      The coursecattree cache consists of a set of small records each containing 3 numbers (id, parent and visible). This is currently stored using set_many which stores each record against its own key.  If you are using a filesystem store for this cache, this results in a large number of tiny files, which exacerbates performance issues when this is rebuilt.  Seeing as the overall set of data is not very large, it seems to make more sense to store the whole array against a single key.

            marxjohnson Mark Johnson
            marxjohnson Mark Johnson
            Tim Hunt Tim Hunt
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Janelle Barcega Janelle Barcega
            Votes:
            1 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours
                6h

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.