_theme_process_registry() includes any include file (could be a template or foo.admin.inc) when building the registry. It looks like including the file isn't necessary.
I traced the include back to
#168028: both theme functions and templates may need include files β
, when that patch went in hook_theme() and especially include file/template handling was very different, and as far as I can tell it's no longer needed. Originally the include had a comment 'just to be safe', this was lost in the past three years.
This saves at least 40ms off a registry rebuild, but more importantly 5mb of memory, with just core modules enabled. Sites with lots of modules, lots of includes and lots of templates are going to see considerably bigger savings.
As well as this, all those included files, many of which are never going to be used if they're templates, will pollute opcode caches - potentially causing evictions etc. - so this should help on cold starts a fair bit.
Theme tests pass but didn't run the whole suite.
If I run drush cc all then hit the front page without apc enabled, that requires 45mb of memory with all the caches being rebuilt.
I confirmed that the total memory usage with this patch dropped to 41mb. So if these includes really aren't needed, that may end up helping with issues like
#1008362: 32M is sometimes not enough memory to install Drupal 7 β
, module page submit - anywhere else where a single request can end up building all global caches.
If this doesn't break things horribly, it may win the award for most kilobytes of memory saved per line of patch ;)
β