Skip to content

Optimize DOM hot path DeltaUpdates to reduce GC pressure #9317

@tobiu

Description

@tobiu

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions