Review main Merged

96333[TASK] Avoid duplicate file-cache size reads

Wouter Wolters CR +2 V +2 Normal +54 −13 updated 11/09/26, 13:48

Commit message

FileBackend reads a cache entry's data size twice on a successful
lookup: once to check its expiry and again to retrieve its contents.

Reuse the size within the same lookup, reducing file opens and read
syscalls from four to three. Keep the expiry check overridable and
discard the shared size when the lookup ends, so subsequent lookups
pick up rewritten entries.

Lookup times with a warm filesystem on PHP 8.5:

Entry size    Before       After        Reduction
256 B         38.34 us     29.29 us      23.6%
4 KiB         39.73 us     29.81 us      25.0%
64 KiB        44.66 us     29.15 us      34.7%
1 MiB         68.38 us     63.08 us       7.8%

The temporary size map adds 376 bytes of peak PHP memory in these
cases. These gains apply to FileBackend lookups; the default page
cache uses a different backend.

Review

  • Code review CR +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Oliver Klee +1
    • Alexander Schnitzler +1
  • Verified V +2 Done
    • Benni Mack +2
    • Georg Ringer +1
    • Oliver Klee +1
    • Alexander Schnitzler +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 1516

  1. Wouter Wolters uploaded patch set 1 10/02/26, 19:50

  2. Wouter Wolters updated the commit message in patch set 2 10/02/26, 20:06

  3. Wouter Wolters updated the commit message in patch set 3 10/02/26, 20:09

  4. Wouter Wolters updated the commit message in patch set 4 10/09/26, 18:32

  5. Wouter Wolters rebased onto patch set 5 10/09/26, 18:32

  6. Wouter Wolters wrote 10/09/26, 18:33

    Unset private
  7. Wouter Wolters marked it ready for review 10/09/26, 18:33

  8. core-ci voted on patch set 5 V +1 10/09/26, 18:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/110683

  9. Simon Schaufelberger commented on patch set 5 10/17/26, 17:36

    FileBackend.php:34

    I'm not sure if a RuntimeCache would be better here because I think the core team doen't like local cache variables so much
  10. Alexander Schnitzler commented on patch set 5 10/18/26, 06:53

    FileBackend.php:34 Reply

    What do you mean with a RuntimeCache here? A static variable is a first level runtime cache. We have those in various places. Extbase uses those in the Reflection area quite a lot. Not sure who doesn’t like this pattern but I would build this like Wouter does here.
  11. Oliver Klee voted on patch set 5 CR +1 V +1 10/18/26, 09:23

  12. Simon Schaufelberger commented on patch set 5 10/18/26, 12:21

    FileBackend.php:34 Reply

    I mean the runtime cache from the caching framework. Just wanted to mention this, I'm not asking to change it.
  13. Alexander Schnitzler voted on patch set 5 CR +1 V +1 10/18/26, 13:34

  14. Georg Ringer voted on patch set 5 CR +1 V +1 11/01/26, 16:04

  15. Benni Mack commented on patch set 5 CR +2 V +2 11/09/26, 13:48

    FileBackend.php:34 Reply

    Done
  16. Benni Mack merged patch set 6 11/09/26, 13:48