Frontmatter
| id | 9400 |
| title | Performance: O(1) Fast Paths for onScrollCapture getById Traversal |
| state | Closed |
| labels | enhancementaiarchitectureperformance |
| assignees | tobiu |
| createdAt | Mar 8, 2026, 10:16 PM |
| updatedAt | Mar 8, 2026, 10:35 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9400 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 8, 2026, 10:35 PM |
Performance: O(1) Fast Paths for onScrollCapture getById Traversal
tobiu assigned to @tobiu on Mar 8, 2026, 10:23 PM

tobiu
Mar 8, 2026, 10:23 PM
Input from Gemini 3.1 Pro:
✦ Task Completed:
- Introduced
O(1)fast paths intoonScrollCaptureinsrc/component/Abstract.mjsandsrc/component/Base.mjs.- The framework now checks
target.id === me.id,target.id === me.vnode.id, andtarget.id === me.getVnodeItemsRoot()?.idbefore falling back toVNodeUtil.getById.- This eliminates the need to recursively crawl massive VDOM structures (like Grids) on every single scroll frame when the node scrolling is the component's main scroll wrapper.
- This effectively reclaims the ~7.8% App Worker CPU overhead identified in the performance trace.
tobiu closed this issue on Mar 8, 2026, 10:35 PM
Problem: During continuous scrolling of a complex Grid, profiling reveals that
VDomUtil.getByIdandVNodeUtil.getByIdconsume a combined ~7.8% of the App Worker's total CPU time (nearly 700ms in a 1-minute trace).This overhead is generated by the generic
onScrollCapturelisteners insrc/component/Abstract.mjsandsrc/component/Base.mjs. For every single scroll event, the framework naively dumps the eventtarget.idintogetById(me.vnode, target.id), which forces a full recursive tree traversal, even if the node that is scrolling is the component's root node or its designated content wrapper.Proposed Solution: Introduce O(1) Fast Paths in
onScrollCaptureto check the most common scrolling targets before falling back to the expensive deep traversal:target.idequalme.vnode.id?target.idequalme.id? (Essential for components usinggetVdomRootwrappers, where the inner node receivesme.id).target.idequalme.getVdomItemsRoot().id?These three checks will short-circuit practically all internal grid and container scrolling events, completely eliminating the deep recursive
getByIdpenalty.