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

Performance: Course category tree cache is stored in multiple keys

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.8.1
    • Fix Version/s: 3.9
    • Component/s: Caching
    • Testing Instructions:
      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.  
    • Affected Branches:
      MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_39_STABLE
    • Pull 3.7 Branch:
      MDL-67681_37_STABLE
    • Pull 3.8 Branch:
      MDL-67681_38_STABLE
    • Pull Master Branch:
      MDL-67681_master

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              marxjohnson Mark Johnson
              Reporter:
              marxjohnson Mark Johnson
              Peer reviewer:
              Tim Hunt
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Matteo Scaramuccia, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                8/Jun/20

                  Time Tracking

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