Project

General

Profile

Actions

Task #98137

closed

Drop usage of "flush"-tag on apcu cache backend

Added by Mordamir over 2 years ago. Updated 10 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Caching
Target version:
-
Start date:
2022-08-13
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
apcu cache backend
Complexity:
no-brainer
Sprint Focus:

Description

The current acpu cache backend uses a tag (APCBE) to mark all entries as belonging to this cache, so it can simply use flushByTag() to clear the cache on flush(). I think this is a behaviour from old old apc times where it wasn't easy to detect all entries of a cache. With the APCUIterator it is much more easy to find all entries with the same identifier prefix. So i think the usage of a tag to mark all entries isn't necessary anymore.

The main problems with the "flush"-tag are:
  1. Cache fragmentation: this is caused by the cache entry for the flush-tag. This entry needs to be rewritten for every new or deleted cache entry, which not only slows down the setting of new entries. The new cache entry for the tag does not fit in its old place, because the new cache entry is very likely written after the entry for the tag, so the new cache entry needs to be relocated, leaving a new free small memory segment in the cache.
  2. Additional cache entries necessary: every cache entry using a tag also needs a reverse search entry (ident_ - key). If we set a tag for every cache entry, we also need this additional reverse search entry, even for caches which do not use tags. So for every new cache entry at least 3 cache writes are necessary: the cache entry itself, the flush-tag and the reverse search entry.
  3. Set-performance: Especially for caches with many entries, the set performance is very bad. For every cache set we need to read the flush-tag, deserialize the large array of cache identifiers, append the new identifier, serialize this whole array and write it back to the cache to a (very likely) new memory position.

We could simply prevent all this problems by using the APCUIterator for the flush() function.

I try to create a patch for this.

Actions

Also available in: Atom PDF