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

Remove unnecessary database writes (updates basically) on full gradebook recalculations

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Test 1

      1. Create a course, enrol a user
      2. Create activities 1, 2 and 3 and a manual grade item all of them with 0 mingrade and 100 maxgrade, move 3 and the manual grade item in a new "category 1" and create a "category 2" this last one without items on it, both the grade categories and the course using 'Natural' aggregation method
      3. Set the following grades to the student:
        1 2 3 manual
        50 10 20 40
      4. Go to the student user report, check that the calculated weight of each grade item is correct, they should all be a 25%, although the ones inside "category 1" will appear as 50% inside the category they would result in a 25% because the category is only the 50% of the total. "category 2" calculated weight should be 0% (empty).
      5. Move item 3 to "category 2" and return to the student user report, all items weight should still be a 25%, but both "category 1" and "category 2" totals should be now a 100% instead of a 50%
      6. Move "category 1" inside "category 2" and go to the user report, calculated weights should result in the following distribution
        1 2 manual cat 1 total 3 cat 2 total
        25% 25% 100% 50% 50% 50%
      7. Move item 3 to "category 1" along with the manual grade item, edit "category 1" and set "Drop the lowest" to 1.
      8. Return to the user report, the last changes should result in
        1 2 manual 3 cat 1 total cat 2 total
        33% 33% 100% 0% (dropped) 100% 33%

      Test 2 (repeat this test at least with mysql and postgres)

      1. Create a M size test course with tool_generator and set MDL_PERF vars in config.php so the performance info is displayed on the page's footer
      2. Go to the gradebook and try any action (create or add a grade item or category) that will trigger a course gradebook recalculation, don't close this page with the MDL_PERF results
      3. Revert MDL-53309 patch (git log --grep MDL-53309 ; git revert -m 1 THE_MERGE_COMMIT_HASH) and open a new tab to compare the same action results with the previous tab results.
      4. The gradebook recalculation with MDL-53309 patch in should perform better
      Show
      Test 1 Create a course, enrol a user Create activities 1, 2 and 3 and a manual grade item all of them with 0 mingrade and 100 maxgrade, move 3 and the manual grade item in a new "category 1" and create a "category 2" this last one without items on it, both the grade categories and the course using 'Natural' aggregation method Set the following grades to the student: 1 2 3 manual 50 10 20 40 Go to the student user report, check that the calculated weight of each grade item is correct, they should all be a 25%, although the ones inside "category 1" will appear as 50% inside the category they would result in a 25% because the category is only the 50% of the total. "category 2" calculated weight should be 0% (empty). Move item 3 to "category 2" and return to the student user report, all items weight should still be a 25%, but both "category 1" and "category 2" totals should be now a 100% instead of a 50% Move "category 1" inside "category 2" and go to the user report, calculated weights should result in the following distribution 1 2 manual cat 1 total 3 cat 2 total 25% 25% 100% 50% 50% 50% Move item 3 to "category 1" along with the manual grade item, edit "category 1" and set "Drop the lowest" to 1. Return to the user report, the last changes should result in 1 2 manual 3 cat 1 total cat 2 total 33% 33% 100% 0% (dropped) 100% 33% Test 2 (repeat this test at least with mysql and postgres) Create a M size test course with tool_generator and set MDL_PERF vars in config.php so the performance info is displayed on the page's footer Go to the gradebook and try any action (create or add a grade item or category) that will trigger a course gradebook recalculation, don't close this page with the MDL_PERF results Revert MDL-53309 patch (git log --grep MDL-53309 ; git revert -m 1 THE_MERGE_COMMIT_HASH) and open a new tab to compare the same action results with the previous tab results. The gradebook recalculation with MDL-53309 patch in should perform better
    • Affected Branches:
      MOODLE_29_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-53309_master-second-attempt
    • Sprint:
      3.1 Sprint 7

      Description

      While debugging I found out that when we add a new grade_item we are calling update() through set_hidden in all its hierarchy categories even if there are no changes in their visibility, only because if the new grade_item is visible and the category hidden, we should make it visible, and this continues through all the tree up until the course. Many unnecessary update() calls (= cache invalidations) if all the hierarchy is already visible.

      Changing this may highlight other issues, but if any grade_object has the need to be updated it shouldn't be through set_hidden, I mean that if I change $gi->attr = 12312 and later call set_hidden(false) I should not rely in set_hidden update() call, I should call it separately. I'd like opinions on this even I don't fully believe in this change and I think it is very dangerous. But would help MDL-48838 as each change in grade_categories, even if we are calling update() to change, notify_cached is being called and grade_categories cache purged.

      Updating the issue's title as set_hidden is only affecting new grade categories and expanding its scope to other write actions.

        Attachments

          Activity

            People

            • Votes:
              1 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                23/May/16