Project

General

Profile

Actions

Task #99852

closed

Improve performance of TreeController::pagesToFlatArray

Added by Alexander Grein about 1 year ago. Updated 3 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Pagetree
Target version:
-
Start date:
2023-02-06
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
8.1
Tags:
Complexity:
medium
Sprint Focus:

Description

The pagesToFlatArray method of the TYPO3\CMS\Backend\Controller\Page\TreeController has some performance optimization potential.

Currenytly it calls the getPageTreeRepository method multible times. This is even more worse, since this method calls itself recursivly!

Since the getPageTreeRepository method always returns the same result in one request, it could be handover as an additional parameter to the pagesToFlatArray method.

Doing this, the getPageTreeRepository method is called only once, which reduces the rendertime significant.

I did some measurements with a simple page tree with around 20 pages, max 2 levels deep and was able to reduce the response time of a /record/tree/fetchData call from 370 ms to 270 ms!

Imaging what an impact this could have on huge page trees with around 1000 pages in multible levels!

Another possible optimization is to change the way of the array_merge done inside the fetchDataAction, filterDataAction and again pagesToFlatArray.

PHPStorm mark all the places with a red underline and this hint:

array_merge(...) is used in a loop and is a ressources greedy construction.

The help of PhpStorm contains a link to this page:
https://github.com/kalessil/phpinspectionsea/blob/master/docs/performance.md#slow-array-function-used-in-loop

Maybe this helps to improve the performance even more.

I will try to create a patchset within the next days.

Actions #1

Updated by Gerrit Code Review about 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/+/77750

Actions #2

Updated by Gerrit Code Review about 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/+/77750

Actions #3

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/+/77750

Actions #4

Updated by Gerrit Code Review about 1 year 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/+/77750

Actions #5

Updated by Gerrit Code Review about 1 year 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/+/77750

Actions #6

Updated by Gerrit Code Review about 1 year ago

Patch set 6 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/+/77750

Actions #7

Updated by Gerrit Code Review about 1 year ago

Patch set 7 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/+/77750

Actions #8

Updated by Gerrit Code Review about 1 year ago

Patch set 8 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/+/77750

Actions #9

Updated by Alexander Grein about 1 year ago

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

Updated by Gerrit Code Review about 1 year ago

  • Status changed from Resolved to Under Review

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

Actions #11

Updated by Gerrit Code Review about 1 year ago

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

Actions #12

Updated by Alexander Grein about 1 year ago

  • Status changed from Under Review to Resolved
Actions #13

Updated by Benni Mack 3 months ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF