Review main Merged

77235[TASK] Use runtime cache in `PageRepository::getPageOverlaysForLanguage()`

Christoph Lehmann CR +2 V +2 Easy +12 −4 updated 01/22/23, 21:07

Commit message

The function is called several times during menu/page generation with
the same arguments.

Its query results are now cached in the runtime cache to spend less
time doing SQL queries.

This streamlines the behaviour in default lanuage where
`PageRepository::getPage()` already uses the runtime cache.

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Georg Ringer +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Georg Ringer +1
    • core-ci +1 CI

Issues 1

Files 1

Review log 2936

Show 711 earlier messages
  1. Christoph Lehmann uploaded patch set 1 12/28/22, 15:25

  2. core-ci voted on patch set 1 V -1 12/28/22, 15:56 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35377

  3. Christoph Lehmann marked it work in progress 12/28/22, 17:25

  4. Christoph Lehmann uploaded patch set 2 V -1 12/28/22, 21:05

  5. core-ci voted on patch set 2 V -1 12/28/22, 21:16 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35380

  6. Christoph Lehmann uploaded patch set 3 V -1 12/29/22, 20:13

  7. core-ci voted on patch set 3 V +1 12/29/22, 20:21 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35395

  8. Christoph Lehmann updated the commit message in patch set 4 V +1 12/29/22, 20:23

  9. Christoph Lehmann marked it ready for review 12/29/22, 20:23

  10. Christoph Lehmann commented on patch set 4 12/29/22, 20:26

    In my test with a ~50 pages sitemap the amount of queries went down from 486 to 325
  11. core-ci voted on patch set 4 V +1 12/29/22, 20:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35396

  1. Benni Mack voted on patch set 4 CR +1 01/09/23, 14:06

  2. Jörg Bösche voted on patch set 4 CR +1 01/11/23, 09:23

  3. Christoph Lehmann uploaded patch set 5 CR +1 V +1 01/17/23, 16:23

  4. core-ci voted on patch set 5 V +1 01/17/23, 16:30 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/35979

  5. Benni Mack voted on patch set 5 V +1 CR +1 01/19/23, 16:52

  6. Stefan Bürk voted on patch set 5 V +1 CR +1 01/19/23, 23:18

  7. Georg Ringer commented on patch set 5 V -1 CR -1 01/20/23, 06:46

    just tested it and if > $rows = $query->executeQuery()->fetchAllAssociative(); returns an empty row, the query is still always called because "if ($cacheEntry) {" will be triggered with empty array AND false
  8. Christoph Lehmann uploaded patch set 6 CR +1 V +1 01/20/23, 10:29

  9. Stefan Bürk commented on patch set 5 V 0 CR 0 01/20/23, 10:32

    Maybe we should think about dropping the backport here. Backport needs quite some side changes, as the array chunking stuff has not been backported as it seems. How should we proceed there with the backport ? Would say let''s drop it. If it works out we can do a complete dedicated backport later ?

    Reply

    good catch. Should be an `is_array($cacheEntry)` here.
  10. Stefan Bürk commented on patch set 6 01/20/23, 10:32

    Reply

    unresolve ;)
  11. core-ci voted on patch set 6 V +1 01/20/23, 10:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36321

  12. Christoph Lehmann commented on patch set 6 01/20/23, 11:44

    Reply

    It's fine for me, I will care about and provide it later.

    Reply

    Done
  13. Andreas Kienast commented on patch set 6 01/20/23, 13:30

    PageRepository.php:591

    I guess this could be shortened to ``` if (($rows = $this->getRuntimeCache()->get($cacheIdentifier)) === false) { $rows = $query->executeQuery()->fetchAllAssociative(); $this->getRuntimeCache()->set($cacheIdentifier, $rows); } ```
  14. Stefan Bürk commented on patch set 6 01/20/23, 13:41

    PageRepository.php:591 Reply

    would not do the assignment in the condition. But you are right, but would rework it more like that - what do you think ? ``` $cacheIdentifier = 'PageRepository_getPageOverlaysForLanguage_' . hash('xxh3', $query->getSQL() . json_encode($query->getParameters())); $rows = $this->getRuntimeCache()->get($cacheIdentifier); if (!is_array($rows)) { $rows = $query->executeQuery()->fetchAllAssociative(); $this->getRuntimeCache()->set($cacheIdentifier, $rows); } ```
  15. Andreas Kienast commented on patch set 6 01/20/23, 13:57

    PageRepository.php:591 Reply

    Looks fine to me.
  16. Andreas Kienast uploaded patch set 7 V +1 01/20/23, 14:16

  17. Andreas Kienast commented on patch set 7 01/20/23, 14:17

    PageRepository.php:591 Reply

    Done
  18. Stefan Bürk voted on patch set 7 V +1 CR +1 01/20/23, 14:21

  19. Christoph Lehmann commented on patch set 7 01/20/23, 14:36

    Please wait with merge.
  20. core-ci voted on patch set 7 V +1 01/20/23, 14:51 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/36368

  21. Georg Ringer voted on patch set 7 V +1 CR +1 01/20/23, 20:24

  22. Stefan Bürk commented on patch set 7 CR -1 01/20/23, 21:16

    Reply

    Find, but can you enlight us, why ? What are we/I missing ? (Temp -1 for that reason)
  23. Christoph Lehmann commented on patch set 7 01/22/23, 19:41

    Reply

    Sure. I re-checked its benefit in combination with * https://review.typo3.org/c/Packages/TYPO3.CMS/+/77387 * https://review.typo3.org/c/Packages/TYPO3.CMS/+/77484 * https://review.typo3.org/c/Packages/TYPO3.CMS/+/77519 and came to the conclusion that the benefit is there. Interestingly I saw a lower memory peak WITH this change while rendering a sitemap menu. Together with that, the description in this issue is still valid, so please, let's merge it.
  24. Stefan Bürk voted on patch set 7 V +2 CR +2 01/22/23, 21:07

  25. Stefan Bürk merged patch set 8 01/22/23, 21:07