LearnNewsExamplesServices
Frontmatter
id9318
titleOptimize VDom Helper hot paths to reduce GC pressure
stateClosed
labels
enhancementai
assigneestobiu
createdAtFeb 26, 2026, 11:03 PM
updatedAtFeb 26, 2026, 11:06 PM
githubUrlhttps://github.com/neomjs/neo/issues/9318
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 26, 2026, 11:06 PM

Optimize VDom Helper hot paths to reduce GC pressure

Closed v12.0.0 enhancementai
tobiu
tobiu commented on Feb 26, 2026, 11:03 PM

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.

tobiu added the enhancement label on Feb 26, 2026, 11:03 PM
tobiu added the ai label on Feb 26, 2026, 11:03 PM
tobiu referenced in commit dc13a71 - "perf: Optimize VDom Helper hot paths to reduce GC pressure (#9318)" on Feb 26, 2026, 11:06 PM
tobiu assigned to @tobiu on Feb 26, 2026, 11:06 PM
tobiu
tobiu Feb 26, 2026, 11:06 PM

Input from Gemini 3.1 Pro:

✦ The optimizations for the VDOM worker hot paths have been implemented and pushed to dev.

Key changes:

  1. Helper.mjs: Replaced Object.keys().forEach and Object.entries().forEach with for...in loops in compareAttributes and createVnode to avoid array allocations and closure overhead.
  2. Helper.mjs: Refactored .forEach on childNodes arrays into for loops in createVnodeMap, findMovedNodes, and getFragmentPhysicalCount.
  3. Helper.mjs: Changed Object.entries().forEach to for...in in updateBatch.
  4. VNode.mjs: Optimized normalizeClassName to use plain for loops instead of .forEach and .filter(Boolean).

Closing this ticket.

tobiu closed this issue on Feb 26, 2026, 11:06 PM