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

All module strings are fetched from the cache, regardless of whether they are needed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.6.3, 3.7.2, 3.8
    • Fix Version/s: 3.8
    • Component/s: Performance
    • Labels:
    • Testing Instructions:
      Hide
      1. Enable perfdebug to show the cache hits/misses in the page footer. In config.php:

        $CFG->perfdebug = 15;
        define('MDL_PERF', true);
        define('MDL_PERFTOLOG', true);
        define('MDL_PERFTOFOOT', true);
        

      2. Disable developer debugging, otherwise lang strings will still be fetched from the cache, even with lazy loading.
      3. In the cache configuration, set the core/string cache to use a cachestore_file.
      4. Create a course containing a forum and a wiki, and nothing else.
      5. In a separate (say chrome and firefox, surely incognito sessions are also ok) browser, view the course as a student. Reload the page to ensure that the caches have been primed.
      6. Look at the perfdebug info in the footer.  Note the number of cache hits for core/string in cachestore_file (the number before the first slash).
      7. Edit the course (in the first browser again), add a Page to the course.
      8. Back in the second browser, reload the course page.
        1. Note the number of cache hits for core/string in cachestore_file again.  It should have increased by 1.
      9. Edit the course (in the first browser again), remove the Page from the course.
      10. Back in the second browser, reload the course page.
        1. Note the number of cache hits for core/string in cachestore_file again.  It should have returned to the original value.
      Show
      Enable perfdebug to show the cache hits/misses in the page footer. In config.php: $CFG->perfdebug = 15; define('MDL_PERF', true); define('MDL_PERFTOLOG', true); define('MDL_PERFTOFOOT', true); Disable developer debugging, otherwise lang strings will still be fetched from the cache, even with lazy loading. In the cache configuration, set the core/string cache to use a cachestore_file. Create a course containing a forum and a wiki, and nothing else. In a separate (say chrome and firefox, surely incognito sessions are also ok) browser, view the course as a student. Reload the page to ensure that the caches have been primed. Look at the perfdebug info in the footer.  Note the number of cache hits for core/string in cachestore_file (the number before the first slash). Edit the course (in the first browser again), add a Page to the course. Back in the second browser, reload the course page. Note the number of cache hits for core/string in cachestore_file again.  It should have increased by 1. Edit the course (in the first browser again), remove the Page from the course. Back in the second browser, reload the course page. Note the number of cache hits for core/string in cachestore_file again.  It should have returned to the original value.
    • Workaround:
      Hide

      Store the lang cache in a local file store, to avoid network round trips.

      Show
      Store the lang cache in a local file store, to avoid network round trips.
    • Affected Branches:
      MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE
    • Fixed Branches:
      MOODLE_38_STABLE
    • Pull 3.5 Branch:
      MDL-65327_35_STABLE
    • Pull 3.6 Branch:
      MDL-65327_36_STABLE
    • Pull 3.7 Branch:
      MDL-65327_37_STABLE
    • Pull Master Branch:
      MDL-65327_master

      Description

      While doing some performance testing, we noticed that the course_modinfo::get_used_module_names() method was fetching a lot of lang files from the cache.  If the time taken to fetch things from the cache isn't optimal (e.g. it's a network round-trip away), this can cause a performance issue.

      Looking into it, this function calls get_module_types_names to get the names of all modules, then decides if each one is used on the course.  This is called in several places "in case its needed" or in cases where we want to get a particular module name.  If we can lazy-load these string, it will reduce the required cache fetches to just those modules that are used in a lot of cases.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                18/Nov/19

                Time Tracking

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 hour, 25 minutes
                1h 25m