diff --git a/core/lib/Drupal/Core/Update/UpdateRegistry.php b/core/lib/Drupal/Core/Update/UpdateRegistry.php
index be0711a5c40222a4fcb6c001d366d54271d1cd5f..4db46fc36933b61aa788863e3d2a99de57695357 100644
--- a/core/lib/Drupal/Core/Update/UpdateRegistry.php
+++ b/core/lib/Drupal/Core/Update/UpdateRegistry.php
@@ -67,6 +67,16 @@ class UpdateRegistry implements EventSubscriberInterface {
    */
   protected $sitePath;
 
+  /**
+   * A static cache of all the extension updates scanned for.
+   *
+   * This array is keyed by Drupal root, site path, extension name and update
+   * type. The value if the extension has been searched for is TRUE.
+   *
+   * @var array
+   */
+  protected static array $loadedFiles = [];
+
   /**
    * Constructs a new UpdateRegistry.
    *
@@ -185,6 +195,7 @@ protected function loadUpdateFile(Extension $extension) {
     if (file_exists($filename)) {
       include_once $filename;
     }
+    self::$loadedFiles[$this->root][$this->sitePath][$extension->getName()][$this->updateType] = TRUE;
   }
 
   /**
@@ -247,12 +258,15 @@ public function registerInvokedUpdates(array $function_names) {
    */
   public function getUpdateFunctions($extension_name) {
     $this->scanExtensionsAndLoadUpdateFiles($extension_name);
-    $all_functions = $this->getAvailableUpdateFunctions();
 
-    return array_filter($all_functions, function ($function_name) use ($extension_name) {
-      [$function_extension_name] = explode("_{$this->updateType}_", $function_name);
-      return $function_extension_name === $extension_name;
-    });
+    $updates = [];
+    $functions = get_defined_functions();
+    foreach (preg_grep('/^' . $extension_name . '_' . $this->updateType . '_/', $functions['user']) as $function) {
+      $updates[] = $function;
+    }
+    // Ensure that the update order is deterministic.
+    sort($updates);
+    return $updates;
   }
 
   /**
@@ -263,6 +277,10 @@ public function getUpdateFunctions($extension_name) {
    *   extension.
    */
   protected function scanExtensionsAndLoadUpdateFiles(string $extension = NULL) {
+    if ($extension !== NULL && isset(self::$loadedFiles[$this->root][$this->sitePath][$extension][$this->updateType])) {
+      // We've already checked for this file and, if it exists, loaded it.
+      return;
+    }
     // Scan for extensions.
     $extension_discovery = new ExtensionDiscovery($this->root, TRUE, [], $this->sitePath);
     $module_extensions = $extension_discovery->scan('module');