Frontmatter
| id | 9438 |
| title | TreeStore: Reduce GC pressure and redundant iterations |
| state | Closed |
| labels | enhancementaiperformancegrid |
| assignees | tobiu |
| createdAt | Mar 11, 2026, 11:09 AM |
| updatedAt | Mar 11, 2026, 11:14 AM |
| githubUrl | https://github.com/neomjs/neo/issues/9438 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 9404 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| contentTrust | |
| projected | |
| quarantined | 0 |
| signals | [] |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 11, 2026, 11:14 AM |
TreeStore: Reduce GC pressure and redundant iterations

tobiu
Mar 11, 2026, 11:13 AM
Input from Gemini 3.1 Pro:
✦ I have applied all the requested optimizations:
- Added
#rebuildKeysAndCount()to pre-allocate the_keysarray, eliminating the.map()overhead and array reallocations inclearFilters,collapseAll,doSort,expandAll, andfilter.- Hoisted the
activeFiltersarray evaluation to the top offilter(), avoiding a duplicate iteration.- Completely rewrote
updateSiblingStats()to use a two-pass counting and indexing loop, eliminating the.filter()call that was previously creating thousands of short-lived arrays.All unit tests pass successfully. The commit has been pushed. Closing this optimization sub-ticket.
Goal
Optimize
TreeStore.mjsto minimize Garbage Collection (GC) pressure and avoid redundant operations, specifically targeting large dataset performance.Context
During operations like
filter,doSort, and bulk expands, theTreeStorecan trigger thousands of array allocations and function invocations, significantly stressing the GC.Acceptance Criteria
updateSiblingStats()to remove the.filter()array allocation, using a two-pass counter instead.activeFilterscalculation infilter()to avoid duplicate iteration.#rebuildKeysAndCount()that pre-allocates the_keysarray instead of using.map(). Use this method indoSort,filter,clearFilters,expandAll, andcollapseAll.