Review main Merged

91284[BUGFIX] Improve pagetree performance

Benjamin Franzke CR +2 V +2 Normal +70 −25 updated 11/13/26, 08:09

Commit message

* Use indexes for the tree node map to solve a bottleneck in
  getNodeByTreeIdentifier
* Throttle re-render on scroll by rendering more visible nodes
  in advance and using a threshold to detect once a rerender
  should be scheduled

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Andreas Nedbal +1
    • Josua Vogel +1
    • Benjamin Kott +1
    • Ayke Halder +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Andreas Nedbal +1
    • Josua Vogel +1
    • Benjamin Kott +1
    • core-ci +1 CI

Issues 1

Files 4

Review log 1420

  1. Benjamin Franzke uploaded patch set 1 10/27/25, 17:59

  2. core-ci voted on patch set 1 V -1 10/27/25, 18:27 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87705

  3. Benjamin Franzke uploaded patch set 2 V -1 10/27/25, 18:28

  4. core-ci voted on patch set 2 V -1 10/27/25, 18:45 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87713

  5. Benjamin Franzke uploaded patch set 3 V -1 10/27/25, 20:18

  6. core-ci voted on patch set 3 V -1 10/27/25, 20:29 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87734

  7. Benjamin Franzke uploaded patch set 4 V -1 10/28/25, 09:52

  8. core-ci voted on patch set 4 V +1 10/28/25, 09:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87786

  9. Benjamin Franzke uploaded patch set 5 V +1 10/28/25, 10:30

  10. core-ci voted on patch set 5 V +1 10/28/25, 10:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87789

  11. Benjamin Franzke uploaded patch set 6 V +1 10/28/25, 11:02

  12. Benjamin Kott voted on patch set 6 CR +1 V +1 10/28/25, 11:16

  13. core-ci voted on patch set 6 V +1 10/28/25, 11:20 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/87801

  14. Andreas Nedbal commented on patch set 6 CR +1 V +1 10/28/25, 11:40

    Works great! Also verified because I was working on the exact same issue right now and came to basically the same conclusion :D
  15. Josua Vogel commented on patch set 6 CR +1 V +1 10/28/25, 11:45

    Works in our customer project. It performs much better. If a large number of pages are open, there is still a very slight delay (milliseconds) , but this should not cause any problems. Thank you very much for the fix! Awesome job!
  16. Benjamin Franzke voted on patch set 6 CR +2 V +2 10/28/25, 11:46

  17. Benjamin Franzke merged patch set 7 10/28/25, 11:48

  18. Ayke Halder commented on patch set 7 CR +1 10/28/25, 14:56

    tree.ts:48

    I like! 🙌

    tree.ts:500

    Nice one here, removing the expensive calls to `this.nodes.find()` 👍 See https://review.typo3.org/c/Packages/TYPO3.CMS/+/88227/comments/4f0bb02e_c9dc1d18 > 2) Object-storage of the tree-nodes is implemented as array > > The tree-nodes don't know their parents, resulting in complex calculations to find the parent each time when there is a tree change. > > On tree-rendering the function getParentNode calls getNodeByTreeIdentifier which calls this.nodes.find(…) inside an iterative loop. > > Time used to find parents is around 30 ms total on opening/closing any sub-tree. > > I think Big-O complexity of the calculation is O(n^(m²)) > with n: number of visible nodes (~20-30) > and m: depth of tree (3-4). > > By storing each child-node with a reference to its parent node, the time of searching for parents can be reduced from O(n^(m²)) [30 ms] to O(n) [2-3 ms].
  19. Garvin Hicking commented on patch set 7 10/28/25, 15:19

    thanks so much for investigating and addressing this. I think you made some people very happy!
  20. Ayke Halder commented on patch set 7 11/13/26, 08:09

    Unresolved

    Some further performance improvement I got in mind here.

    tree.ts:429 Unresolved

    This might be refactored and the order reversed: 1. First create `TreeNodeMap` 2. Then use this very `TreeNodeMap` to implement a fast implementation for `this.enhanceNodes(nodes)` Background: * `this.enhanceNodes` runs in a loop over each node using `nodes.reduce()` and then calls `findLast()` to get the praent node of each node! * Getting the parent node fast, is what this `TreeNodeMap` is all about.

    tree.ts:562 Unresolved

    `findLast()` is computational expensive - and is run inside a loop `nodes.reduce()`.