LearnNewsExamplesServices
Frontmatter
id9317
titleOptimize DOM hot path DeltaUpdates to reduce GC pressure
stateClosed
labels
enhancementai
assigneestobiu
createdAtFeb 26, 2026, 11:00 PM
updatedAtFeb 26, 2026, 11:02 PM
githubUrlhttps://github.com/neomjs/neo/issues/9317
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtFeb 26, 2026, 11:02 PM

Optimize DOM hot path DeltaUpdates to reduce GC pressure

tobiu
tobiu commented on Feb 26, 2026, 11:00 PM

This ticket covers a set of optimizations in the hot path of DOM updates (src/main/DeltaUpdates.mjs and src/main/render/DomApiRenderer.mjs).

The main thread can process batches of 600+ deltas at a time. The previous implementations relied on Array.from().find() for NodeLists and Object.entries().forEach() for object iteration, which creates significant garbage collection (GC) pressure due to intermediate array allocations and closure creation.

Changes:

  1. Replaced Array.from(childNodes).find(...) with standard for loops in DeltaUpdates.mjs (getFragmentNodes, removeNode, updateVtext).
  2. Replaced Object.entries(delta).forEach(...) with for...in loops in DeltaUpdates.updateNode and DomApiRenderer.createDomTree for attributes and styles.
  3. Removed a duplicate getFragmentNodes method from DeltaUpdates.mjs.

These changes should yield a measurable reduction in memory allocations and frame drops during intense update phases.

tobiu
tobiu Feb 26, 2026, 11:01 PM

Input from Gemini 3.1 Pro:

✦ The optimizations have been successfully implemented and pushed to the dev branch.

  • Replaced all instances of Array.from().find() with for loops in DeltaUpdates.mjs to eliminate array allocations.
  • Replaced Object.entries().forEach() with for...in loops in updateNode and DomApiRenderer.createDomTree to avoid temporary arrays and closures.
  • Removed the duplicate getFragmentNodes method in DeltaUpdates.mjs.

These changes should significantly reduce GC pressure in the main thread during heavy DOM update operations. Closing this ticket.