Skip to content

Optimize VDom Helper hot paths to reduce GC pressure #9318

@tobiu

Description

@tobiu

This ticket continues the GC pressure reduction effort, focusing on the VDOM worker's hot paths (src/vdom/Helper.mjs and src/vdom/VNode.mjs).

The VDom Worker can generate thousands of delta updates. Array allocations and closures inside looping constructs create significant GC pressure.

Changes:

  1. Replaced Object.keys().forEach() and Object.entries().forEach() with for...in loops in Helper.compareAttributes and Helper.createVnode.
  2. Refactored .forEach loops on child arrays to use standard for loops in Helper.createVnodeMap, Helper.findMovedNodes, and Helper.getFragmentPhysicalCount.
  3. Optimized normalizeClassName in VNode.mjs to avoid .filter(Boolean) and .forEach closures.
  4. Converted Object.entries().forEach() to for...in in Helper.updateBatch.

These optimizations will make the VDOM generation and diffing process much lighter on memory allocations.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions