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

Preload contexts in course_filter_selector

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.5
    • 3.4
    • Calendar
    • MOODLE_34_STABLE
    • MOODLE_35_STABLE
    • MDL-60967-master
    • Hide

      Test calendar page

      1. Download the attached script create_a_bunch_of_stuff.php and save it in the root directory of your moodle install
      2. Run the script and give it a seed value (a) from the command line (this will be used in the usernames and course names it generates to keep them unique). The script will generate 400 courses with a few activities and enrol a student user in each one.
        • E.g. php create_a_bunch_of_stuff.php a
      3. Log in as admin
      4. Turn on performance debugging (perfdebug)
        • Site administration > development > debugging
      5. Log in as the student (sa1) - the password will just be test
      6. View the calendar
      7. Edit your config.php and add define('CONTEXT_CACHE_MAX_SIZE', 310); to the top of the file. This means we have more courses than can be stored in the context cache and sets us up to replicate the scenario where the calendar trashes the cache.
      8. Edit your calendar/renderer.php file and comment out the change from this patch. The whole if (!empty($courses) && count($courses) > CONTEXT_CACHE_MAX_SIZE) conditional in the course_filter_selector function.
      9. Reload the calendar page (the context cache will get thrashed on this page load)
      10. Note the number of DB reads in the performance info in the bottom of the page
      11. Uncomment the if condition in calendar/renderer.php which will re-apply this patch
      12. Reload the calendar page with the patch applied
      13. CONFIRM that the number of DB reads is lower than it was previously
      14. CONFIRM that the events are showing up in the side mini 3 month block correctly
      15. Change the calendar to the next month
      16. CONFIRM that the mini 3 month block updates correctly to show the new month

      Test calendar block

      1. Log in as admin
      2. Go to the "Site home" page
      3. Add the calendar block
        1. Turn editing on
        2. Click "Add a block" in the nav drawer
      4. Log out
      5. CONFIRM that the calendar block loads without errors
      6. Log in as the student (sa1 from the example)
      7. CONFIRM that the calendar block loads without errors
      8. CONFIRM that you can navigate the calendar block using the little arrows to change month
      Show
      Test calendar page Download the attached script create_a_bunch_of_stuff.php and save it in the root directory of your moodle install Run the script and give it a seed value (a) from the command line (this will be used in the usernames and course names it generates to keep them unique). The script will generate 400 courses with a few activities and enrol a student user in each one. E.g. php create_a_bunch_of_stuff.php a Log in as admin Turn on performance debugging (perfdebug) Site administration > development > debugging Log in as the student (sa1) - the password will just be test View the calendar Edit your config.php and add define('CONTEXT_CACHE_MAX_SIZE', 310); to the top of the file. This means we have more courses than can be stored in the context cache and sets us up to replicate the scenario where the calendar trashes the cache. Edit your calendar/renderer.php file and comment out the change from this patch. The whole if (!empty($courses) && count($courses) > CONTEXT_CACHE_MAX_SIZE) conditional in the course_filter_selector function. Reload the calendar page (the context cache will get thrashed on this page load) Note the number of DB reads in the performance info in the bottom of the page Uncomment the if condition in calendar/renderer.php which will re-apply this patch Reload the calendar page with the patch applied CONFIRM that the number of DB reads is lower than it was previously CONFIRM that the events are showing up in the side mini 3 month block correctly Change the calendar to the next month CONFIRM that the mini 3 month block updates correctly to show the new month Test calendar block Log in as admin Go to the "Site home" page Add the calendar block Turn editing on Click "Add a block" in the nav drawer Log out CONFIRM that the calendar block loads without errors Log in as the student (sa1 from the example) CONFIRM that the calendar block loads without errors CONFIRM that you can navigate the calendar block using the little arrows to change month

      For larger users the course_filter_selector can load more courses than can be held in the course context cache which means each of them loads the context from the DB again in a loop.

      Instead we should just preload all of the contexts for the required courses in a single query. We could even have it check if the number courses are likely to exceed the context static cache limit and only do the preloading if it looks like we'll thrash the cache otherwise.

            ryanwyllie Ryan Wyllie
            ryanwyllie Ryan Wyllie
            Simey Lameze Simey Lameze
            David Monllaó David Monllaó
            Marina Glancy Marina Glancy
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

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