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

Course Overview Block Performance

XMLWordPrintable

    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MOODLE_402_STABLE, MOODLE_403_STABLE
    • MDL-78370-403
    • MDL-78370-main
    • Hide

      Do not select the "All" option in the "Show" items per page menu if the user is enrolled in more than 100 courses. Select a lower value for the "Show" menu as much as possible.

      Show
      Do not select the " All " option in the " Show " items per page menu if the user is enrolled in more than 100 courses. Select a lower value for the " Show " menu as much as possible.
    • Hide
      Notes
      1. This is easier to test with MDK.
      2. The @block_myoverview Behat tests should be able to confirm the overall functionality of the My courses page.
      Setup
      1. Open a terminal and edit your php.ini as a privileged user. e.g. in Ubuntu Linux, using Gnome Editor

        sudo gedit /etc/php/[VERSION]/php.ini
        

      2. Set max_execution_time to 0 just to make sure to avoid execution timeout errors.
      3. Restart your web server. e.g.

        sudo service httpd restart
        or
        sudo service apache2 restart
        

      4. Create a freshly-installed Moodle instance with some users.

        mdk create -t -i -r users
        

      Site with < 100 courses
      1. Download course_generator.php to your Moodle instance's root folder.
      2. Run the script to create courses wit less than 100 courses. For example

        php course_generator.php 100
        

      3. Enrol users to the courses

        mdk run enrol
        

      4. Log in as a student
      5. Go to My courses
      6. Make sure the display mode is either set to Card or List view
      7. Switch to Summary view
      8. Confirm that the view includes the summary texts for the courses.
      9. For each display mode, check the "Show" menu (items per page control) on the lower right corner.
      10. Confirm that you can see the "All" option and doing so will load all the courses
      Site with > 100 courses
      1. On the browser, switch back to the Card or List view.
      2. Set the "Show" menu to "96"
      3. On the terminal, run the course generator script to generate a total of 500 courses. If you entered 100 earlier, it will create 400 more courses instead

        php course_generator.php 500
        

      4. Enrol users to the generated courses

        mdk run enrol
        

      5. On the browser, open your browser dev tools
      6. Go to the Network tab
      7. Filter the results by entering "core_course_get_enrolled_courses_by_timeline_classification" to the Filter text box in the Network tab.
      8. Reload the My courses page a few times. Take note of the Time column. e.g. the AJAX request for "core_course_get_enrolled_courses_by_timeline_classification" may finish in around half a second, but the total page load will finish in about 3 seconds.
      9. Confirm that the "Show" menu does not have an "All" option.
      10. Switch the view to "Summary"
      11. Confirm that the "Show" menu does not have an "All" option.
      12. Reload the My courses page a few times. Take note of the Time column. e.g. the AJAX request for "core_course_get_enrolled_courses_by_timeline_classification" may finish in around 1 second, but the total page load will finish in about 3 seconds.
      Comparing performance before the patch
      1. Checkout a version of your Moodle instance before the patch.

        git checkout d3ad77e4762
        

      2. Purge caches
      3. Switch back to the Card or List view
      4. Reload the My courses page a few times
      5. The AJAX request may finish in about the same amount of time as the Summary view with 96 courses shown per page. (e.g. With the patch, loading 96 courses will be around half a second on the Card view and about 1 second in Summary view. Without the patch, the Card and Summary views will be loaded in about 1 second)
      6. Before the patch, the "All" option will be present in both Card, List, and Summary views and selecting "All" will load the courses in a long time. (e.g. if it takes about 1 second to load 96 courses, then it will take about 6 seconds to load all of the courses)
      Show
      Notes This is easier to test with MDK . The @block_myoverview Behat tests should be able to confirm the overall functionality of the My courses page. Setup Open a terminal and edit your php.ini as a privileged user. e.g. in Ubuntu Linux, using Gnome Editor sudo gedit /etc/php/[VERSION]/php.ini Set max_execution_time to 0 just to make sure to avoid execution timeout errors. Restart your web server. e.g. sudo service httpd restart or sudo service apache2 restart Create a freshly-installed Moodle instance with some users. mdk create -t -i -r users Site with < 100 courses Download course_generator.php to your Moodle instance's root folder. Run the script to create courses wit less than 100 courses. For example php course_generator.php 100 Enrol users to the courses mdk run enrol Log in as a student Go to My courses Make sure the display mode is either set to Card or List view Switch to Summary view Confirm that the view includes the summary texts for the courses. For each display mode, check the " Show " menu (items per page control) on the lower right corner. Confirm that you can see the " All " option and doing so will load all the courses Site with > 100 courses On the browser, switch back to the Card or List view. Set the " Show " menu to " 96 " On the terminal, run the course generator script to generate a total of 500 courses. If you entered 100 earlier, it will create 400 more courses instead php course_generator.php 500 Enrol users to the generated courses mdk run enrol On the browser, open your browser dev tools Go to the Network tab Filter the results by entering " core_course_get_enrolled_courses_by_timeline_classification " to the Filter text box in the Network tab. Reload the My courses page a few times. Take note of the Time column. e.g. the AJAX request for " core_course_get_enrolled_courses_by_timeline_classification " may finish in around half a second, but the total page load will finish in about 3 seconds. Confirm that the " Show " menu does not have an " All " option. Switch the view to " Summary " Confirm that the " Show " menu does not have an " All " option. Reload the My courses page a few times. Take note of the Time column. e.g. the AJAX request for " core_course_get_enrolled_courses_by_timeline_classification " may finish in around 1 second, but the total page load will finish in about 3 seconds. Comparing performance before the patch Checkout a version of your Moodle instance before the patch. git checkout d3ad77e4762 Purge caches Switch back to the Card or List view Reload the My courses page a few times The AJAX request may finish in about the same amount of time as the Summary view with 96 courses shown per page. (e.g. With the patch, loading 96 courses will be around half a second on the Card view and about 1 second in Summary view. Without the patch, the Card and Summary views will be loaded in about 1 second) Before the patch, the " All " option will be present in both Card, List, and Summary views and selecting "All" will load the courses in a long time. (e.g. if it takes about 1 second to load 96 courses, then it will take about 6 seconds to load all of the courses)
    • 2
    • Team Hedgehog 2024 Sprint 1.1, Team Hedgehog 2024 Sprint 1.2, Team Hedgehog 2024 Sprint 1.3

      Course Overview Block for a user with 300+ course enrolments is throwing "Failed to load resource: the server responded with a status of 500" error. (out of memory)

      Issue has been tracked back to "core_course_get_enrolled_courses_by_timeline_classification" and more specifically to https://github.com/moodle/moodle/blob/MOODLE_402_STABLE/course/classes/external/course_summary_exporter.php#L96-L99 which is fetching the course summary of every course a user is enrolled in.  Course summary could contain html, images, long text, etc. and should not really be fetched by the query to populate the course overview block for users due to performance implications.

       

      When we commented out course_summary_exporter.php#L96-L99 the course overview block loads without an error and within couple of seconds after cache purge.

      We also checked all the course summaries in the database and deleted all course summaries that contained any type of html which also made the courses to load but it was taking 20-30 seconds to load all courses after a cache purge.

       

       

        1. image-2023-10-17-14-00-08-082.png
          24 kB
          Alistair Spark
        2. course_generator.php
          2 kB
          Jun Pataleta
        3. MDL-78370 500.png
          406 kB
          Ron Carl Alfon Yu
        4. MDL-78370 before.png
          472 kB
          Ron Carl Alfon Yu
        5. MDL-78370 100.png
          869 kB
          Ron Carl Alfon Yu

            jpataleta Jun Pataleta
            nbozhkov Nikola Bozhkov
            Huong Nguyen Huong Nguyen
            Ilya Tregubov Ilya Tregubov
            Ron Carl Alfon Yu Ron Carl Alfon Yu
            Votes:
            14 Vote for this issue
            Watchers:
            35 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 days, 1 hour, 8 minutes
                3d 1h 8m

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