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

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

XMLWordPrintable

      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

       

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

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.