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

Improve performance of get_imageinfo

    XMLWordPrintable

Details

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

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

      Setup
      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().
      Before patch
      1. Navigate to any file picker such as /user/files.php and upload several images one by one
      2. Confirm as you upload each image loading the page will become progressively slower
      3. Reload the page
      4. You'll see that the page reloads slow (e.g. if you uploaded 3 images, it will take at least 3 seconds to load the page)
      After patch
      1. Apply the patch, purge caches
      2. Reload the page, the first reload will take a little longer
      3. Reload the page again and confirm the performance is back to being fast
      4. 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: Setup 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() . Before patch Navigate to any file picker such as /user/files.php and upload several images one by one Confirm as you upload each image loading the page will become progressively slower Reload the page You'll see that the page reloads slow (e.g. if you uploaded 3 images, it will take at least 3 seconds to load the page) After patch Apply the patch, purge caches Reload the page, the first reload will take a little longer Reload the page again 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
              Jun Pataleta Jun Pataleta
              John Edward Pedregosa John Edward Pedregosa
              Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo, Matteo Scaramuccia, David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                28/Nov/22

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 15 minutes
                  1h 15m