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

Enable profiling of PHPUnit runs

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.2
    • Fix Version/s: 3.2
    • Component/s: Performance, Unit tests
    • Labels:
    • Testing Instructions:
      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.
    • Affected Branches:
      MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull Master Branch:

      Description

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mr-russ Russell Smith
                Reporter:
                mr-russ Russell Smith
                Peer reviewer:
                Dan Poltawski
                Integrator:
                David Monllaó
                Tester:
                Rajesh Taneja
                Participants:
                Component watchers:
                Matteo Scaramuccia, Jake Dallimore, Jun Pataleta, Ryan Wyllie, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  5/Dec/16