Unverified Commit e3857514 authored by Alex Pott's avatar Alex Pott
Browse files

perf: #3587415 Avoid querying for last installed schema definitions twice

By: catch
parent c9798f85
Loading
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -88,7 +88,25 @@ public function getLastInstalledDefinitions() {
    }, $keys);

    $this->entityTypeDefinitions = array_combine($keys, $entity_type_definitions);
    $this->cacheBackend->set('entity_type_definitions.installed', $this->entityTypeDefinitions, Cache::PERMANENT);

    // Also populate the static and persistent cache for the field storage
    // definitions to avoid a separate key/value lookup when all definitions are
    // looked up first.
    $items = [
      'entity_type_definitions.installed' => [
        'data' => $this->entityTypeDefinitions,
        'expires' => Cache::PERMANENT,
      ],
    ];
    foreach ($keys as $key) {
      $this->entityFieldStorageDefinitions[$key] = $all_definitions[$key . '.field_storage_definitions'] ?? [];
      $items[$key . '.field_storage_definitions.installed'] = [
        'data' => $this->entityFieldStorageDefinitions[$key],
        'expires' => Cache::PERMANENT,
      ];
    }

    $this->cacheBackend->setMultiple($items);
    return $this->entityTypeDefinitions;
  }

+4 −4
Original line number Diff line number Diff line
@@ -126,12 +126,12 @@ protected function doTestNodePageAdministrator(): void {
    }, 'administratorNodePage');

    $expected = [
      'QueryCount' => 272,
      'CacheGetCount' => 266,
      'QueryCount' => 263,
      'CacheGetCount' => 257,
      'CacheGetCountByBin' => [
        'config' => 62,
        'bootstrap' => 16,
        'discovery' => 84,
        'discovery' => 75,
        'data' => 19,
        'entity' => 24,
        'dynamic_page_cache' => 1,
@@ -139,7 +139,7 @@ protected function doTestNodePageAdministrator(): void {
        'render' => 18,
        'menu' => 22,
      ],
      'CacheSetCount' => 265,
      'CacheSetCount' => 256,
      'CacheDeleteCount' => 0,
      'CacheTagInvalidationCount' => 0,
      'CacheTagLookupQueryCount' => 28,
+3 −3
Original line number Diff line number Diff line
@@ -52,9 +52,9 @@ protected function testFrontPageColdCache(): void {
    $this->assertSession()->pageTextContains('Umami');

    $expected = [
      'QueryCount' => 192,
      'CacheGetCount' => 241,
      'CacheSetCount' => 246,
      'QueryCount' => 183,
      'CacheGetCount' => 232,
      'CacheSetCount' => 237,
      'CacheDeleteCount' => 0,
      'CacheTagLookupQueryCount' => 24,
      'CacheTagInvalidationCount' => 0,
+3 −3
Original line number Diff line number Diff line
@@ -55,9 +55,9 @@ protected function testNodePageColdCache(): void {
    $this->assertSession()->pageTextContains('quiche');

    $expected = [
      'QueryCount' => 208,
      'CacheGetCount' => 232,
      'CacheSetCount' => 231,
      'QueryCount' => 199,
      'CacheGetCount' => 223,
      'CacheSetCount' => 222,
      'CacheDeleteCount' => 0,
      'CacheTagLookupQueryCount' => 23,
      'CacheTagInvalidationCount' => 0,