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

Reduce de-referencing on MUC and static acceleration

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 3.0.2
    • Fix Version/s: 3.1
    • Component/s: Caching, Performance
    • Labels:
    • Testing Instructions:
      Hide

      1. Run all unit and behat tests. They must pass.

      Setup

      • Ensure your language string cache (langstringcache) is turned on.
      • Ensure your DEVELOPER_DEBUG is turned off, as is performance debugging.
      • Ensure you visit the Moodle homepage (as a login in user if required) after each cache purge.

      1. Run attached test performance script on the previous weekly build a number of times.
      2. move to this weeks build that includes the changes.
      3. Run attached test performance script again. Compare the changes.

      Show
      1. Run all unit and behat tests. They must pass. Setup Ensure your language string cache (langstringcache) is turned on. Ensure your DEVELOPER_DEBUG is turned off, as is performance debugging. Ensure you visit the Moodle homepage (as a login in user if required) after each cache purge. 1. Run attached test performance script on the previous weekly build a number of times. 2. move to this weeks build that includes the changes. 3. Run attached test performance script again. Compare the changes.
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull Master Branch:

      Description

      1. serialize and unserialize are used widely to manage objects in the cache. There are multiple layers of completing this resulting in wasted cycles.
      2. There are a large amount of function calls to check the if and how something should be unreferenced. This could be simplified and reduced.
      3. most stores already store data in a serialized fashion, so when it comes back from the store it's already had references resolved. This can be told to the loader and be a performance win.
      4. static acceleration is designed to be write low and read high. However it does all the heavy lifting for dereferencing on a get call. Objects could be serialized on set if required and just a single unserialize on loading. This will reduce the serialize or clone overhead when using the static cache.
      5. uses_simple_data should be trusted by the loader to know unreference is never required, including from the static acceleration. This can be determined without nesting into the unref function.
      6. static acceleration delete does an array_search, when the keys are available and an isset() and unset() would be sufficient to remove entries.
      7. static acceleration does not need keys parsed as it's stored on a per cache basis.

      These changes can provide a significant performance improvement for complex structures and some improvement for simple data cases. In cases where simpledata is used with static acceleration but the simpledata is an object, there can be good gains because in the current structure static acceleration still did function calls when simple_data was set.

      Overall see the basic attached file that tests the runtime of a complex array of objects (databasemeta) and also does the same for simple_data and simple_keys by testing get_string. Those two formed the basis for the performance improvements.

      Basic loading of pages has not seen significant performance improvements for smaller faster pages. However for pages that complete lots of databasemeta lookups, there are much bigger gains.

        Attachments

        1. integration.mpr
          11 kB
        2. master-coursemod-php56-filestore.mpr
          9 kB
        3. master-string-php56-memcache.mpr
          8 kB
        4. patch-coursemod-php56-filestore.mpr
          9 kB
        5. patch-string-php56-memcache.mpr
          9 kB
        6. production.mpr
          10 kB
        7. test.php
          2 kB

          Issue Links

            Activity

              People

              • Votes:
                3 Vote for this issue
                Watchers:
                9 Start watching this issue

                Dates

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