Why /Drupal\Core\Form\FormBuilder->renderPlaceholderFormAction is taking so long? I'm profiling drupal 8 website in New Relic

Report shows me that method:  


  /Drupal\Core\Form\FormBuilder->renderPlaceholderFormAction


takes ~2sec.

This method is called in:


  \Drupal\Core\Render\Renderer->doRender


Code related to execution:

// Build the element if it is still empty.
if (isset($elements['#lazy_builder'])) {
  $callable = $elements['#lazy_builder'][0];
  $args = $elements['#lazy_builder'][1];
  if (is_string($callable) &amp;&amp; strpos($callable, '::') === FALSE) {
    $callable = $this-&gt;controllerResolver-&gt;getControllerFromDefinition($callable);
  }
  $new_elements = call_user_func_array($callable, $args);
  // Retain the original cacheability metadata, plus cache keys.
  CacheableMetadata::createFromRenderArray($elements)
    -&gt;merge(CacheableMetadata::createFromRenderArray($new_elements))
    -&gt;applyTo($new_elements);
  if (isset($elements['#cache']['keys'])) {
    $new_elements['#cache']['keys'] = $elements['#cache']['keys'];
  }
  $elements = $new_elements;
  $elements['#lazy_builder_built'] = TRUE;
}


Method code:

 /**
   * #lazy_builder callback; renders a form action URL.
   *
   * @return array
   *   A renderable array representing the form action.
   */
  public function renderPlaceholderFormAction() {
    return [
      '#type' =&gt; 'markup',
      '#markup' =&gt; $this-&gt;buildFormAction(),
      '#cache' =&gt; ['contexts' =&gt; ['url.path', 'url.query_args']],
    ];
  }

 /**
   * Builds the $form['#action'].
   *
   * @return string
   *   The URL to be used as the $form['#action'].
   */
  protected function buildFormAction() {
    // @todo Use &lt;current&gt; instead of the master request in
    //   https://www.drupal.org/node/2505339.
    $request = $this-&gt;requestStack-&gt;getMasterRequest();
    $request_uri = $request-&gt;getRequestUri();

    // Prevent cross site requests via the Form API by using an absolute URL
    // when the request uri starts with multiple slashes..
    if (strpos($request_uri, '//') === 0) {
      $request_uri = $request-&gt;getUri();
    }

    // @todo Remove this parsing once these are removed from the request in
    //   https://www.drupal.org/node/2504709.
    $parsed = UrlHelper::parse($request_uri);
    unset($parsed['query'][static::AJAX_FORM_REQUEST], $parsed['query'][MainContentViewSubscriber::WRAPPER_FORMAT]);
    return $parsed['path'] . ($parsed['query'] ? ('?' . UrlHelper::buildQuery($parsed['query'])) : '');
  }


I don't get it at all. This is basic method, no rocket science and 2 sec of execution :( 

New Relic output:
Pretty sure that report is bogus. 

That's just an arbitrary method, not a controller. They somehow identify that as the controller for that request but of course that doesn't make sense. That page lists transactions, so complete requests, not single method calls. So some requests take 2s which it incorrectly identifies as this.

Looks like new relic still can't reliably detect the route/controller for a request. Try our new relic module: https://www.drupal.org/project/new_relic_rpm. It reports the route name for the controller, then you'll see what kind of request this actually is.