Do custom theme suggestions execute on every page load and does that impact performance? I've been working with Drupal for a little while now and one nagging question I've had is about whether or not logic in my *.theme or *.module files have any impact on server load.

Let's say I have this bit of code in my *.theme file:

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function MY_THEME_theme_suggestions_page_alter(array &amp;$suggestions, array $variables) {

  if(\Drupal::routeMatch()-&gt;getRouteName() == 'entity.node.edit_form' &amp;&amp; \Drupal::routeMatch()-&gt;getParameter('node')-&gt;bundle() === 'blog_general') {
    $suggestions[] = 'page__no_sidebars';
  }
}


This bit of code adds a template theme at the page.html level. I only need this for about 1% of my site and it bothers me a little that this would need to execute on every page load just so 1% of my site can templated correctly. 

So my question is, would this code get executed on every page load? Or does the caching take care of it? If it does execute on every page load then this one bit of code might be trivial. However, I'm slowly building up a lot of these types of altering hooks and it's bugging me that they could be taxing the server.

I appreciate any insights. Thanks!
To answer your questions:


Yes, it executes on every page load.
It won't impact your server load any noticeable amount.


The amount of processing power for that one function is extremely low. You could probably run it 1000 times without causing a noticeable performance it.