Frontmatter
| id | 9319 |
| title | Optimize Grid hot paths to reduce GC pressure |
| state | Closed |
| labels | enhancementai |
| assignees | tobiu |
| createdAt | Feb 26, 2026, 11:08 PM |
| updatedAt | Feb 26, 2026, 11:13 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9319 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Feb 26, 2026, 11:13 PM |
Optimize Grid hot paths to reduce GC pressure
tobiu assigned to @tobiu on Feb 26, 2026, 11:12 PM

tobiu
Feb 26, 2026, 11:12 PM
Input from Gemini 3.1 Pro:
✦ The grid hot path optimizations have been successfully implemented, and a syntax error (
len is not defined) has been fixed. Changes have been pushed todev.Key changes:
src/grid/Body.mjs: Replaced all.forEach()loops iterating overme.itemswith highly efficient standardforloops. This affects config setters,destroy(),getColumnCells, andonStoreRecordChange.src/grid/Row.mjs: ReplacedObject.values(this.components).forEach()withfor...inloops to avoid allocating arrays of values and closures during component state updates (afterSetMounted,afterSetTheme,updateCellComponents) and destruction. Refactored the.forEachonoldCnto a standardforloop increateVdomrecycling.src/grid/Container.mjs: Converted.forEachiterations inbulkUpdateRecords,createColumns, andremoveSortingCssto standardforloops.These changes should significantly reduce GC pressure during rapid grid scrolling and rendering. Closing this ticket.
tobiu closed this issue on Feb 26, 2026, 11:13 PM
This ticket optimizes the hot paths within the buffered grid to reduce GC pressure and improve scrolling/rendering performance.
The Grid's virtual scrolling mechanism relies heavily on iterating over rows, columns, and cell components. Using
.forEach()with inline arrow functions in these tight loops allocates arrays (likeObject.values()) and closures repeatedly.Changes:
src/grid/Body.mjs: Replaced.forEach()loops with highly efficientforloops, particularly in hot paths likeonStoreRecordChange,getColumnCells, and config setters that iterate overme.items.src/grid/Row.mjs: ReplacedObject.values(me.components).forEach()withfor...inloops to avoid intermediate array allocations and closures during component state updates and destruction. Refactored.forEachonoldCnto a standardforloop during cell VDOM recycling.src/grid/Container.mjs: Replaced.forEachincreateColumns,bulkUpdateRecords, andremoveSortingCsswithforloops.These optimizations are crucial for maintaining 60fps scrolling performance, especially when rapidly recycling rows with many cell components.