Project

General

Profile

Actions

Task #98137

closed

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

Added by Mordamir over 1 year ago. Updated 3 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 #1

Updated by Mordamir over 1 year ago

  • Tracker changed from Feature to Task
  • TYPO3 Version set to 12

Changed tracker from Feature to Task, because no new functionality added.

Actions #2

Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75438

Actions #3

Updated by Gerrit Code Review over 1 year ago

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75440

Actions #4

Updated by Mordamir over 1 year ago

Sorry, missed a use statement in my first typo3 push.

Actions #5

Updated by Mordamir over 1 year ago

Looks like i cannot comment on the gerrit server.

The 10.4 Version is coming from the template from the typo3 contribution page. I didn't change that. Integration in 11.5 would be ok.
This is not a bug fix, typo3 could work for years without this patch. Its more that it makes the apcu cache backend work much better.

Actions #6

Updated by Gerrit Code Review over 1 year ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75438

Actions #7

Updated by Gerrit Code Review about 1 year ago

Patch set 3 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75438

Actions #8

Updated by Gerrit Code Review 10 months ago

Patch set 4 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75438

Actions #9

Updated by Gerrit Code Review 9 months ago

Patch set 5 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/75438

Actions #10

Updated by Gerrit Code Review 9 months ago

Patch set 1 for branch 12.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/80139

Actions #11

Updated by Mordamir 9 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #12

Updated by Benni Mack 3 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF