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

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

XMLWordPrintable

    • MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
    • MDL-68441-caching-filters
    • 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).

      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.

            Unassigned Unassigned
            kristianr Kristian Ringer
            Votes:
            2 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved:

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