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

Review the memory usage of the evaluation process and the initial training process

XMLWordPrintable

    • MOODLE_37_STABLE
    • MOODLE_36_STABLE, MOODLE_37_STABLE
    • MDL-65839_master
    • Hide

      These testing instructions only work for 37 and master

      Prerequisites

      1. Pull in a commit to test this issue

        git fetch git://github.com/dmonllao/moodle.git MDL-65839_master-test
        git cherry-pick FETCH_HEAD
        

      Test

      1. Enable debugging mode
      2. Log in as admin
      3. Enable 'enablecompletion' in site admin > advanced features
      4. Setup your timezone correctly in site admin > location > location settings
      5. Set up 2 course so that:
        • They uses topics format
        • completion is enabled
        • startdate to right now (including hour and minute)
      6. Enrol 2 users as students in each course
      7. Enrol the logged in admin user as a course teacher in both courses
      8. We need the courses to have a page activity in a course section different than section 0
        1. Set the "Expected completed on" time (in Activity completion fieldset) to right now (including hour and minute)
      9. Set both course end dates to right now
      10. Click on the courses admin cog and select Course completion
      11. Set Condition: Manual completion by others to Teacher role
      12. Go to course admin > more... > reports > course completion
      13. Flag just one of the students in each course as approved
      14. Run cron so that the course completion status of the student is updated
      15. Go to site admin > analytics > analytics models
      16. Click on new model > create model
      17. Set the following values in the form:
        1. Tick 'enabled'
        2. Target: Students at risk of not meeting the course completion conditions
        3. Indicators: Page cognitive
        4. Analysis interval: No time limits
        5. Default value for predictions processor
        6. Save changes
      18. Go to CLI and execute the following commands, replacing I_AM_AN_ID by the id of the Students at risk of not meeting the course completion conditions model:
        php admin/tool/analytics/cli/evaluate_model.php --list
        php admin/tool/analytics/cli/evaluate_model.php --analysisinterval='\core\analytics\time_splitting\no_splitting' --modelid=I_AM_AN_ID
      19. There is no need to wait for the process to finish, but you SHOULD see something like the output below. The important part is that the memory used after instantiate_indicators for the second analysable element is lower than the memory used before the instantiate_indicators call. In the example below these values are 32652.3KB and 32611.5KB.

        Analysing id "15" with "No time limits" time splitting method...
        Before instantiate_indicators
        27032.8KB - real: 28672KB - process: 66832KB - peak: 30720KB
        After instantiate_indicators
        27033.3KB - real: 28672KB - process: 66832KB - peak: 30720KB
        ..
        Analysing id "14" with "No time limits" time splitting method...
        Before instantiate_indicators
        32652.3KB - real: 34816KB - process: 73449.2KB - peak: 34816KB
        After instantiate_indicators
        32611.5KB - real: 34816KB - process: 73449.2KB - peak: 34816KB
        

      Finally

      1. Don't forget to remove the extra commit you added to test this issue.
      Show
      These testing instructions only work for 37 and master Prerequisites Pull in a commit to test this issue git fetch git://github.com/dmonllao/moodle.git MDL-65839_master-test git cherry-pick FETCH_HEAD Test Enable debugging mode Log in as admin Enable 'enablecompletion' in site admin > advanced features Setup your timezone correctly in site admin > location > location settings Set up 2 course so that: They uses topics format completion is enabled startdate to right now (including hour and minute) Enrol 2 users as students in each course Enrol the logged in admin user as a course teacher in both courses We need the courses to have a page activity in a course section different than section 0 Set the "Expected completed on" time (in Activity completion fieldset) to right now (including hour and minute) Set both course end dates to right now Click on the courses admin cog and select Course completion Set Condition: Manual completion by others to Teacher role Go to course admin > more... > reports > course completion Flag just one of the students in each course as approved Run cron so that the course completion status of the student is updated Go to site admin > analytics > analytics models Click on new model > create model Set the following values in the form: Tick 'enabled' Target: Students at risk of not meeting the course completion conditions Indicators: Page cognitive Analysis interval: No time limits Default value for predictions processor Save changes Go to CLI and execute the following commands, replacing I_AM_AN_ID by the id of the Students at risk of not meeting the course completion conditions model: php admin/tool/analytics/cli/evaluate_model.php --list php admin/tool/analytics/cli/evaluate_model.php --analysisinterval='\core\analytics\time_splitting\no_splitting' --modelid=I_AM_AN_ID There is no need to wait for the process to finish, but you SHOULD see something like the output below. The important part is that the memory used after instantiate_indicators for the second analysable element is lower than the memory used before the instantiate_indicators call. In the example below these values are 32652.3KB and 32611.5KB. Analysing id "15" with "No time limits" time splitting method... Before instantiate_indicators 27032.8KB - real: 28672KB - process: 66832KB - peak: 30720KB After instantiate_indicators 27033.3KB - real: 28672KB - process: 66832KB - peak: 30720KB .. Analysing id "14" with "No time limits" time splitting method... Before instantiate_indicators 32652.3KB - real: 34816KB - process: 73449.2KB - peak: 34816KB After instantiate_indicators 32611.5KB - real: 34816KB - process: 73449.2KB - peak: 34816KB Finally Don't forget to remove the extra commit you added to test this issue.

      The evaluation process for the students at risk model in learn.moodle.net crashed with a "Killed" message. We got the following message in dmesg:

      [8436702.743468] Memory cgroup out of memory: Kill process 22072 (php) score 1739 or sacrifice child
      [8436702.750325] Killed process 22072 (php) total-vm:3214820kB, anon-rss:754752kB, file-rss:52732kB
      

      The memory usage in learn.moodle.net is 256MB.

      The API was designed keeping the memory usage in mind and there shouldn't be any leaks during the analysis process. The analysis process is designed so that the memory used during the analysis of each analysable element is isolated from the following analysed elements. However, when analysing a specific element we load into memory different stuff. For the students at risk model we load: the course (1), all the participants (N), all the context_user of the participants (N) and all the user_enrolments of the participants (N). N is around 6000. Considering PHP's variables overhead it is possible that massive courses like the ones in learn moodle could take more than 250MB of RAM.

      For sites with massive courses the recommended approach was to bump the memory, because they would have to bump it anyway as many other pages in moodle (like the participants one for example) load all this stuff in memory. We need to check if we are missing something and monitor the memory while evaluating one of these large courses.

            dmonllao David Monllaó
            dmonllao David Monllaó
            Victor Déniz Falcón Victor Déniz Falcón
            Sara Arjona (@sarjona) Sara Arjona (@sarjona)
            Janelle Barcega Janelle Barcega
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 days, 5 hours, 35 minutes
                2d 5h 35m

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