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

Enable profiling of PHPUnit runs

XMLWordPrintable

    • MOODLE_32_STABLE
    • MOODLE_32_STABLE
    • Hide

      === Prior to upgrade
      1. Ensure you have XHProf or Tideways profiler installed
      2. Prior to upgrade, enabled profiling and store some profiles. Label them as pre-upgrade
      3. Export one of those profile runs
      4. Open the database and delete the profiling run from the database
      DELETE from mdl_profiling WHERE runid = '9xxx...';

      === Run upgrade
      Upgrade to the integration version of Moodle that includes these changes.

      === Test operations
      1. Profile a new page and view the profile output's function call list and callgraph.
      2. View a profile of a page that was profiled before the upgrade.
      3. Import the profile that was deleted from the database and view it to confirm it works correctly.

      === Test PHPUnit profiling
      Set $CFG->phpunit_profilingenabled = true; in config.php
      Drop PHPUnit tables if they exist (php admin/tool/phpunit/cli/util.php --drop)
      Install a new PHPUnit setup with profiling enabled (php admin/tool/phpunit/cli/util.php --install)
      Run PHPUnit (use full run to ensure we can import large profiles and view them)
      Drop PHPUnit tables again ensuring no errors (php admin/tool/phpunit/cli/util.php --drop)
      Import the file that is listed at the end of the PHPUnit run as the profile.
      View the function list and call graph to ensure they both appear. These callgraph is slow as it's a large amount of memory and processing.

      Show
      === Prior to upgrade 1. Ensure you have XHProf or Tideways profiler installed 2. Prior to upgrade, enabled profiling and store some profiles. Label them as pre-upgrade 3. Export one of those profile runs 4. Open the database and delete the profiling run from the database DELETE from mdl_profiling WHERE runid = '9xxx...'; === Run upgrade Upgrade to the integration version of Moodle that includes these changes. === Test operations 1. Profile a new page and view the profile output's function call list and callgraph. 2. View a profile of a page that was profiled before the upgrade. 3. Import the profile that was deleted from the database and view it to confirm it works correctly. === Test PHPUnit profiling Set $CFG->phpunit_profilingenabled = true; in config.php Drop PHPUnit tables if they exist (php admin/tool/phpunit/cli/util.php --drop) Install a new PHPUnit setup with profiling enabled (php admin/tool/phpunit/cli/util.php --install) Run PHPUnit (use full run to ensure we can import large profiles and view them) Drop PHPUnit tables again ensuring no errors (php admin/tool/phpunit/cli/util.php --drop) Import the file that is listed at the end of the PHPUnit run as the profile. View the function list and call graph to ensure they both appear. These callgraph is slow as it's a large amount of memory and processing.

      When attempting to look at slow tests and trying to find them out, it became apparent that we would easily use all Moodle's existing infrastructure to produce a PHPUnit performance run.

      This was changed it was discovered DOMDocument doesn't accept > 10Mb data fields. A PHPUnit run produced close to 20Mb of data.

      Adjusting the saving and export of profiles to use gzcompress() means a PHPUnit run is only 2.5Mb. Which is sufficient for future growth before a bigger change to a different format.

      When attempting to load those profiles, they use more memory than Moodle assigns by default. MEMORY_HUGE was added as you will know what you are doing if you have profiling enabled.

            mr-russ Russell Smith
            mr-russ Russell Smith
            Dan Poltawski Dan Poltawski
            David Monllaó David Monllaó
            Rajesh Taneja Rajesh Taneja
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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