Task #99852
closedImprove performance of TreeController::pagesToFlatArray
100%
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.
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
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
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
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
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
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
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
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
Updated by Alexander Grein about 1 year ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset ca079a296bfc459e5096b1594c6a0951114b0667.
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
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
Updated by Alexander Grein about 1 year ago
- Status changed from Under Review to Resolved
Applied in changeset ccadcb341e17a516a8b29df06f50f810cbe1130d.