-
-
Notifications
You must be signed in to change notification settings - Fork 202
Optimize VDom Lifecycle and TreeBuilder hot paths to reduce GC pressure #9320
Copy link
Copy link
Closed
Labels
Description
This ticket addresses GC pressure optimizations within the core VDOM management files: src/manager/VDomUpdate.mjs, src/mixin/VdomLifecycle.mjs, and src/util/vdom/TreeBuilder.mjs.
The VDOM update lifecycle naturally deals with recursive tree building, queueing, and callback execution. By converting standard .forEach array iterations and Map.prototype.forEach iterations to for loops, for...in loops, and for...of loops, we can avoid creating closures and temporary arrays during high-frequency update cycles.
Changes:
src/manager/VDomUpdate.mjs: RefactoredforEachmethods used on Maps (item.children.forEach,this.descendantInFlightMap.forEach) intofor...ofloops (for (const [key, value] of map)). Replaced array.forEachcalls withforloops inexecutePromiseCallbacks,registerInFlightUpdate, andtriggerPostUpdates.src/mixin/VdomLifecycle.mjs: ReplacedObject.keys(updates).forEach,Object.entries(response.vnodes).forEach, and other array.forEachcalls (like insyncVnodeTreeandexecuteVdomUpdate) withfor...inor standardforloops.src/util/vdom/TreeBuilder.mjs: Convertednode[childKey].forEach(item => ...)to a standardforloop in the recursive#buildTreemethod to avoid closure allocations at every node depth.
Reactions are currently unavailable