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

Remove as many file_exists() calls against shared dataroot as possible

Details

    Description

      There are certain pages and code paths that call file_exists() a plain ridiculous number of times looking for files that might exist but typically don't. Like 10,000+ times on a single page!

      One such code path is:

      theme_config::resolve_image_location
      

      This looks for icons in a bunch of locations:

      https://github.com/moodle/moodle/blob/1c10c542f324b285e1326120e3c368e932746e75/lib/outputlib.php#L2017-L2065

      Every single on of those attempts is multiplied here:

      https://github.com/moodle/moodle/blob/1c10c542f324b285e1326120e3c368e932746e75/lib/outputlib.php#L2192-L2213

      The problem is that most shared file systems perform great at reads which are heavily cached, not so great at writes, but importantly they don't cache read exist misses. A typical read miss might be a few hundred microseconds, but 10k of these calls adds up to a couple seconds.

      An example page which is poorly affected is:

      /admin/plugins.php
      

      I've personally never seen the features of falling back to pix icons on dataroot but I'm hesitant to remove it.

      So I'm proposing a very generic settings something like $CFG->allowpixoverrides which if set to false avoids these:

      https://github.com/moodle/moodle/blob/1c10c542f324b285e1326120e3c368e932746e75/lib/outputlib.php#L2025-L2027

      https://github.com/moodle/moodle/blob/1c10c542f324b285e1326120e3c368e932746e75/lib/outputlib.php#L2061-L2063

       

      Attachments

        Issue Links

          Activity

            People

              brendanheywood Brendan Heywood
              brendanheywood Brendan Heywood
              Votes:
              6 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: