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

Improve performance of get_imageinfo

    XMLWordPrintable

Details

    • MOODLE_311_STABLE, MOODLE_401_STABLE
    • MDL-70368-cache-image-metadata
    • Hide

      This is a performance tracker so a before and after comparison is needed:

      1. To simulate expensive latency due to a remote file system hack get_imageinfo_from_path in lib/filestorage/file_system.php and add a sleep(1) just before getimagesize https://github.com/moodle/moodle/blob/master/lib/filestorage/file_system.php#L409
      2. Navigate to any file picker such as /user/files.php and upload several images
      3. Confirm as you upload each image loading the page will become progressively slower
      4. Apply the patch, purge caches
      5. Reload the page and confirm the performance is back to being fast
      6. Add another image, confirm it is 1 second to load and then fast again on a reload
      Show
      This is a performance tracker so a before and after comparison is needed: To simulate expensive latency due to a remote file system hack get_imageinfo_from_path in lib/filestorage/file_system.php and add a sleep(1) just before getimagesize https://github.com/moodle/moodle/blob/master/lib/filestorage/file_system.php#L409 Navigate to any file picker such as /user/files.php and upload several images Confirm as you upload each image loading the page will become progressively slower Apply the patch, purge caches Reload the page and confirm the performance is back to being fast Add another image, confirm it is 1 second to load and then fast again on a reload

    Description

      Getting image metadata from the File API pulls the file back down locally:

      https://github.com/moodle/moodle/blob/master/lib/filestorage/file_system.php#L382-L384

      In particular this gets used in a bunch of places when generating html to render an image tag with the right dimensions.

      This data almost never changes and this is all very inefficient. As this is used so often for thumbnails I'm proposing to make the width and height metadata fields directly in the mdl_files table

      Attachments

        Issue Links

          Activity

            People

              brendanheywood Brendan Heywood
              brendanheywood Brendan Heywood
              Matthew Hilton Matthew Hilton
              Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo, Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Michael Hawkins, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated: