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

Active filters are not cached leading to uneccessary queries on each page load

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Development in progress
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.7.5, 3.8.2, 3.9
    • Fix Version/s: None
    • Component/s: Filters, Performance
    • Labels:
    • Testing Instructions:
      Hide

      We are testing by refreshing the course/view.php page and looking at the footer details from perfdebug.
      1. Turn off all filters, comment out my patch, purge caches, refresh twice (to warm up cache). We get DB reads/writes: 89/0.
      2. Turn on multilang filter and apply to content and headings. Now we see : DB reads/writes: 95/0. It is checking each context on each page load to see if we need an active filter there. There is caching happening within the same request already: https://github.com/moodle/moodle/blob/master/lib/filterlib.php#L1005
      3. Apply the patch, Reload page, we see DB reads/writes: 95/1 Didn't hit cache:core/filters_active [a] cachestore_file: 0 / 3 / 3

      4. Reload again, we get DB reads/writes: 86/0, the active filters are caches between page loads. core/filters_active - cachestore_file: 3 / 0 / 0 (3 hits).
      5. Turn filter off/on in course setting and see that it correctly applies the behaviour to the labels. (When it's off, it will display both english and swedish text).

      Show
      We are testing by refreshing the course/view.php page and looking at the footer details from perfdebug. 1. Turn off all filters, comment out my patch, purge caches, refresh twice (to warm up cache). We get DB reads/writes: 89/0. 2. Turn on multilang filter and apply to content and headings. Now we see : DB reads/writes: 95/0. It is checking each context on each page load to see if we need an active filter there. There is caching happening within the same request already: https://github.com/moodle/moodle/blob/master/lib/filterlib.php#L1005 3. Apply the patch, Reload page, we see DB reads/writes: 95/1 Didn't hit cache:core/filters_active [a] cachestore_file: 0 / 3 / 3 4. Reload again, we get DB reads/writes: 86/0, the active filters are caches between page loads. core/filters_active - cachestore_file: 3 / 0 / 0 (3 hits). 5. Turn filter off/on in course setting and see that it correctly applies the behaviour to the labels. (When it's off, it will display both english and swedish text).
    • Affected Branches:
      MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-68441-caching-filters

      Description

      This other tracker: https://tracker.moodle.org/browse/MDL-67428
      improved filters performance by calling the filter_get_active_in_context() function less times overall. In this tracker, we want to cache the results of this function for the same context.

      Filters don't change that often and so we rack up many DB calls on subsequent page loads for the same context just to get that the filter is still active.

      The cache will need to be invalidated when the filters settings change.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kristianr Kristian Ringer
              Reporter:
              kristianr Kristian Ringer
              Participants:
              Component watchers:
              Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Matteo Scaramuccia, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated: