LearnNewsExamplesServices
Frontmatter
id9400
titlePerformance: O(1) Fast Paths for onScrollCapture getById Traversal
stateClosed
labels
enhancementaiarchitectureperformance
assigneestobiu
createdAtMar 8, 2026, 10:16 PM
updatedAtMar 8, 2026, 10:35 PM
githubUrlhttps://github.com/neomjs/neo/issues/9400
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 8, 2026, 10:35 PM

Performance: O(1) Fast Paths for onScrollCapture getById Traversal

Closed v12.1.0 enhancementaiarchitectureperformance
tobiu
tobiu commented on Mar 8, 2026, 10:16 PM

Problem: During continuous scrolling of a complex Grid, profiling reveals that VDomUtil.getById and VNodeUtil.getById consume 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 onScrollCapture listeners in src/component/Abstract.mjs and src/component/Base.mjs. For every single scroll event, the framework naively dumps the event target.id into getById(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 onScrollCapture to check the most common scrolling targets before falling back to the expensive deep traversal:

  1. Root Node Check: Does target.id equal me.vnode.id?
  2. Logical Root Check: Does target.id equal me.id? (Essential for components using getVdomRoot wrappers, where the inner node receives me.id).
  3. Items Root Check: Does target.id equal me.getVdomItemsRoot().id?

These three checks will short-circuit practically all internal grid and container scrolling events, completely eliminating the deep recursive getById penalty.

tobiu added the enhancement label on Mar 8, 2026, 10:16 PM
tobiu added the ai label on Mar 8, 2026, 10:16 PM
tobiu added the architecture label on Mar 8, 2026, 10:16 PM
tobiu added the performance label on Mar 8, 2026, 10:16 PM
tobiu referenced in commit 116b8f9 - "perf: O(1) Fast Paths for onScrollCapture getById Traversal (#9400)" on Mar 8, 2026, 10:23 PM
tobiu assigned to @tobiu on Mar 8, 2026, 10:23 PM
tobiu
tobiu Mar 8, 2026, 10:23 PM

Input from Gemini 3.1 Pro:

Task Completed:

  • Introduced O(1) fast paths into onScrollCapture in src/component/Abstract.mjs and src/component/Base.mjs.
  • The framework now checks target.id === me.id, target.id === me.vnode.id, and target.id === me.getVnodeItemsRoot()?.id before falling back to VNodeUtil.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 referenced in commit 18444a9 - "docs: Add intent and performance notes to onScrollCapture fast paths (#9400)" on Mar 8, 2026, 10:25 PM
tobiu closed this issue on Mar 8, 2026, 10:35 PM