Issue Task Resolved

#111003Avoid duplicate file-cache size reads

Wouter Wolters 10/09/26, 18:32 updated 11/09/26, 13:50

Description

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.

Reviews 1

History 13

  1. Wouter Wolters commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-11-09T13:50:20+00:00" > 11/09/26, 13:50 </span>

    Applied in changeset commit:f72b6281f74205a1c3f1c15e7457f58a218f028f.