diff --git a/core/lib/Drupal/Core/Menu/LocalTaskManager.php b/core/lib/Drupal/Core/Menu/LocalTaskManager.php
index 70db0b0..97b290e 100644
--- a/core/lib/Drupal/Core/Menu/LocalTaskManager.php
+++ b/core/lib/Drupal/Core/Menu/LocalTaskManager.php
@@ -192,11 +192,21 @@ public function getLocalTasksForRoute($route_name) {
   public function getTasksBuild($route_name) {
     $tree = $this->getLocalTasksForRoute($route_name);
     $build = array();
+
+    // Fetch a bunch of routes at once.
+    $route_names = array();
+    foreach ($tree as $instances) {
+      foreach ($instances as $child) {
+        $route_names[] = $child->getRouteName();
+      }
+    }
+    $routes = $route_names ? $this->routeProvider->getRoutesByNames($route_names) : array();
+
     foreach ($tree as $level => $instances) {
       foreach ($instances as $child) {
         $path = $this->getPath($child);
         // Find out whether the user has access to the task.
-        $route = $this->routeProvider->getRouteByName($child->getRouteName());
+        $route = $routes[$child->getRouteName()];
         $map = array();
         // @todo - replace this call when we have a real service for it.
         $access = menu_item_route_access($route, $path, $map);
