Project

General

Profile

Actions

Bug #98964

closed

Menu object caching creates too many records resulting in huge cache_hash table

Added by Loek Hilgersom over 1 year ago. Updated over 1 year ago.

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

100%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Caching of menu objects causes excessive growth of the cache_hash table on many TYPO3 instances. In many cases, the table is filled with 5 to 10x the amount of records in the cache_pages, and on bigger sites the table can easily grow to several GB's (I have an instance where cache_hash grows to over 3GB, while cache_pages is still at a reasonable 350 to 400MB, with about 10.000 pages in cache). By far, most cache_hash records have an 'ident_MENUDATA' tag.

There are currently multiple problems with the caching of menu objects:

  1. the size of the tables can cause the server to run out of disk space
  2. many records of the created records are never retrieved, caching is pure overhead in this case (menu caching only plays a role at the first rendering of a page, as soon as the page is cached the menu caches are not used anymore for that page, provided you don't use uncached TS menu's...
  3. comparing the content of the cache records showed that many stored menu objects are identical, although the hash (field 'identifier') is different. At the mentioned site, SELECT count(distinct content) FROM cache_hash; resulted in 400 with 3200 records! So every object gets stored about 8 times in average.

Causes

  1. it appears that the calculated hash for storing the records has too many variables, causing identical menu objects to be stored. See $this->hash in AbstractMenuContentObject->makeMenu(). I'm not sure this can avoided with the current code.
  2. menus contain so many states (active, current, etc) that the output of most menus is different for every single page, making caching useless if the page itself is properly cached.

Possible solutions

  1. Benny Mack has created a much better alternative for the current menu objects with the extension b13/menus. This extension solves the issue by not storing all that state information in the menu cache, but adding that later on. This results in menu objects that can actually be re-used on many pages, so caching might actually result in some performance improvement, but of course still only for pages that are not in cache yet.
  2. I have very good experiences with skipping menu caching altogether, and propose to make it optional. Some quick and dirty benchmarking on my project showed a minor performance improvement on first page rendering, and - of course - no difference for cached pages. The large site where it is applied runs smooth as ever, with a very compact database now and no more disk space issues.

I will supply a patch for the second solution.


Related issues 5 (1 open4 closed)

Related to TYPO3 Core - Bug #20329: cache_hash fills up with huge amounts of MENUDATAClosed2009-04-21

Actions
Related to TYPO3 Core - Feature #14277: Start/Stop time for pages is ignored in standard menu objectsAccepted2004-08-20

Actions
Related to TYPO3 Core - Bug #91208: Performance issue in PageRepository for Mega MenusClosedStefan Froemken2020-04-27

Actions
Related to TYPO3 Core - Bug #57953: Rendering time of HMENU is really bad, maybe bug?Closed2014-04-15

Actions
Related to TYPO3 Core - Bug #98985: Property "cache" is not included in MenuProcessorResolved2022-11-03

Actions
Actions

Also available in: Atom PDF