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

Performance issues in Grader report due to inefficient HTML output

XMLWordPrintable

    • MOODLE_403_STABLE, MOODLE_404_STABLE, MOODLE_405_STABLE
    • MOODLE_403_STABLE, MOODLE_404_STABLE
    • MDL-82492-403
    • MDL-82492-404
    • MDL-82492-405
    • Hide
      1. Create a test course with 2000 users and 200 activity modules
        • Modify $paramusers and $paramassignments array values admin/tool/generator/classes/course_backend.php. Change $paramusers from 1000 to 2000 $paramassignments from 100 to 200
        • Run CLI command: php admin/tool/generator/cli/maketestcourse.php --size=M --shortname=SIZE_M
      2. Set PHP memory_limit (/etc/php/8.1/fpm/php.ini) to 1384M
      3. Open created course Grader Report.

      Actual results without the optimization:

      Fatal error: Allowed memory size of 1451229184 bytes exhausted (tried to allocate 248250904 bytes) in /var/www/moodle43/lib/outputrenderers.php on line 3363

      Actual results with the optimization:

      Grading report content loads

      Expected results:

      Grading report content should load

      Show
      Create a test course with 2000 users and 200 activity modules Modify $paramusers and $paramassignments array values admin/tool/generator/classes/course_backend.php. Change $paramusers from 1000 to 2000 $paramassignments from 100 to 200 Run CLI command: php admin/tool/generator/cli/maketestcourse.php --size=M --shortname=SIZE_M Set PHP memory_limit (/etc/php/8.1/fpm/php.ini) to 1384M Open created course Grader Report. Actual results without the optimization: Fatal error: Allowed memory size of 1451229184 bytes exhausted (tried to allocate 248250904 bytes) in /var/www/moodle43/lib/outputrenderers.php on line 3363 Actual results with the optimization: Grading report content loads Expected results: Grading report content should load

      Fix instructions:

      Inside grade/report/grader/lib.php modify get_grade_table method. Inside the $leftrows for each loop at the end, add unsets for $leftrows and $rightrows

      // Extract rows from each side (left and right) and collate them into one row each
      foreach ($leftrows as $key => $row) {
          $row->cells = array_merge($row->cells, $rightrows[$key]->cells);
          $fulltable->data[] = $row;
          unset($leftrows[$key]);
          unset($rightrows[$key]);
      } 

      By unsetting elements in $leftrows and $rightrows arrays after they have been processed and merged into $fulltable->data, the unset free up memory that is no longer needed. This is particularly beneficial when dealing with large datasets, as it helps to minimize the script's overall memory footprint during execution.

            vladaskidanovas vladaskidanovas
            vladaskidanovas vladaskidanovas
            Mark Johnson Mark Johnson
            Mathew May Mathew May
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 10 minutes
                6h 10m

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