Remove 'includes' support from hook_theme()

Created on 3 June 2011, over 13 years ago
Updated 17 January 2025, 4 days ago

_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 ;)

β†’

πŸ“Œ Task
Status

Postponed

Version

11.0 πŸ”₯

Component

theme system

Created by

πŸ‡¬πŸ‡§United Kingdom catch

Live updates comments and jobs are added and updated live.
  • Performance

    It affects performance. It is often combined with the Needs profiling tag.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024