88227[TASK] Reduce number of event-listeners for tree-component
Commit message
Review
-
Code review CR 0
-
Verified V 0
- core-ci +1 CI
Issues 1
Files 6
- Build/Sources/TypeScript/backend/tree/file-storage-tree-container.ts+2 −2
- Build/Sources/TypeScript/backend/tree/page-tree.ts+2 −2
- Build/Sources/TypeScript/backend/tree/tree.ts+107 −26
- typo3/sysext/backend/Resources/Public/JavaScript/tree/file-storage-tree-container.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/tree/page-tree.js+1 −1
- typo3/sysext/backend/Resources/Public/JavaScript/tree/tree.js+27 −30
Review log 1316
-
Ayke Halder uploaded patch set 1 02/15/25, 12:29
-
Ayke Halder commented on patch set 1 02/15/25, 12:33
### Event-listerners in page-module All the event listeners inside shadow DOM might not be included here. #### Before: ```js { "click": 88, "dblclick": 64, "dragstart": 39, "dragover": 32, "dragleave": 32, "dragend": 32, "drop": 32, "focusin": 32, "focusout": 32, "contextmenu": 32, "t3-topbar-update": 6, "keydown": 3, "touchstart": 2, "submit": 1, "reset": 1, "shown.bs.collapse": 1, "input": 1, "tree:initialized": 1, "typo3:tree:node-selected": 1, "typo3:tree:node-context": 1, "typo3:tree:nodes-prepared": 1, "scroll": 1, "mouseover": 1, "mouseout": 1, "mousedown": 1, "typo3-module-load": 1, "typo3-module-loaded": 1, "typo3-iframe-load": 1, "typo3-iframe-loaded": 1, "load": 1 } ``` #### With this patch: ```js { "click": 22, "dblclick": 1, "dragstart": 8, "dragover": 1, "dragleave": 1, "dragend": 1, "drop": 1, "focusin": 1, "focusout": 1, "contextmenu": 1, "t3-topbar-update": 6, "keydown": 3, "touchstart": 2, "submit": 1, "reset": 1, "shown.bs.collapse": 1, "input": 1, "tree:initialized": 1, "typo3:tree:node-selected": 1, "typo3:tree:node-context": 1, "typo3:tree:nodes-prepared": 1, "scroll": 1, "mouseover": 1, "mouseout": 1, "mousedown": 1, "typo3-module-load": 1, "typo3-module-loaded": 1, "typo3-iframe-load": 1, "typo3-iframe-loaded": 1, "load": 1 } ``` -
core-ci voted on patch set 1 V +1 02/15/25, 12:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74179
-
Ayke Halder uploaded patch set 2
V +102/15/25, 12:50 -
core-ci voted on patch set 2 V +1 02/15/25, 12:57 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74180
-
Ayke Halder rebased onto patch set 3
V +102/18/25, 11:11 -
core-ci voted on patch set 3 V +1 02/18/25, 11:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/74305
-
Benni Mack commented on patch set 3 03/28/25, 11:33
Is this an actual issue that fixes a real bug where something is broken, or is this an optimization mainly based on memory consumption / GC which is not perceivable for an editor? -
Ayke Halder commented on patch set 3 03/28/25, 14:55
Reply
About those event-listeners here: they are only part of the problem - and are actually neglectable. On a CPU with low clock speed opening big sub-trees takes around 140 ms (sub-tree already cached, no http-request). Ideally this should be below 100 ms (= perceived instantaneous). Firefox performance reports show: > **140 ms Jank - event processing delay** > Jank markers show when the main event loop of a thread has been busy. It is a good indicator that there may be some kind of performance problem worth investigating. ---- Looking deep into the tree rendering there are two main points which cause delays: ### 1) Tree has a huge number of HTML Elements and SVG-Images Changes of tree nodes trigger lots of native browser function-calls: This is a performance issue of LitElement. ### 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]. -
Ayke Halder commented on patch set 3 10/28/25, 14:53
Reply
"2)" solved in https://review.typo3.org/c/Packages/TYPO3.CMS/+/91284 -
Ayke Halder abandoned the change 10/28/25, 14:53
-
Ayke Halder restored the change 10/28/25, 15:04
-
Benni Mack wrote 04/21/26, 14:57
Removed cc Benni Mack. -
Benni Mack commented on patch set 3 11/10/26, 10:41
the affected issue 106182 is closed... are you going to continue here? -
Ayke Halder commented on patch set 3 11/10/26, 11:01
Reply
Closing for now. I Have to get direct feedback from @ben@bnf.dev on this patch and the related patches - see relation chain. -
Ayke Halder abandoned the change 11/10/26, 11:02
Needs another attempt for completion.