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

mod_choice "choice_get_response_data" is too memory intensive for large amounts of responses

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.1.13, 3.4.2, 3.5.1
    • Fix Version/s: None
    • Component/s: Choice
    • Affected Branches:
      MOODLE_31_STABLE, MOODLE_34_STABLE, MOODLE_35_STABLE

      Description

      The function "choice_get_response_data" uses quite a lot of memory as there is duplication of the responses that come back from the DB.

      This is an issue for choices where there has been a large amount of responses(10,000+) as it's storing both the raw response and parsed response in memory.

      I have posted a quick solution to this, by offsetting the logic to a separate function, ensuring that the response data is not stored in memory longer than it has to be.

       

      Steps to Reproduce:

      1. Enrol 10,000+ users into a course.
      2. Answer choice for all 10,000 users(This can be done programmatically on a test site.)
      3. View a choice via /mod/choice/view.php?id=x
      4. Depending on your memory limit(ours was 128mb) the page will fail to load.

      Commit URL is here: https://github.com/LoneBeta/moodle/commit/4ecf02b3d3a5938b824471e22c6d15ce83056c89

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              andrewavado Andrew Turnbull
              Participants:
              Component watchers:
              Dan Marsden, Jake Dallimore, Jun Pataleta, Ryan Wyllie
            • Votes:
              9 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: