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

Probable performance bug in get_available_completion_tabs / can_edit_bulk_completion

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_33_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE

      Description

      get_available_completion_tabs is called on every page, as part of settings_navigation::initialise. This uses get_available_completion_tabs so that the bulkcompletion tab shows up if you have moodle/course:manageactivities capability in the course, or in any activity that you can see. It is implemented in a way that is very efficient if you do have that capability.

      Unfortunately, most users are students who do not have that capability, so this is the common case, and this seems to be quite inefficient if you have a large course. It ends up calling $mod->uservisible && has_capability('moodle/course:manageactivities', $mod->context) for every activity in the course, and this is taking 0.29 seconds out of a 1.19 second page-load in my load testing. This is is on any page I look at in this example course containing 700 activities/resources. It is making 1400 calls to cm_info::__get (2/3 of the time) and 685 calls to has_capability (1/3 of the time).

      If we coud save that much on every page-load, it would be a big win.

      I have not tried, but I imagine this can be reproduced by creating a medium or large course with System administration > Development > Make test course, and then examining performace of the course page when logged in as a student.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                timhunt Tim Hunt
                Participants:
                Component watchers:
                Sam Marshall, Amaia Anabitarte, Carlos Escobedo, Ferran Recio, Sara Arjona (@sarjona), Víctor Déniz Falcón, Matteo Scaramuccia, Jake Dallimore, Jun Pataleta
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated: