-
-
Notifications
You must be signed in to change notification settings - Fork 202
Collection: Prevent deep cloning and spread operator limits when creating allItems #9332
Copy link
Copy link
Closed
Labels
aibugSomething isn't workingSomething isn't workingperformancePerformance improvements and optimizationsPerformance improvements and optimizations
Description
When a Collection is filtered for the first time, it creates an allItems replica to store the unfiltered dataset:
me.allItems = me.createAllItems({
// ...
items: [...me._items],
// ...
});This causes two severe performance and memory issues for large datasets (e.g., 50k+ items in Turbo Mode):
- Spread Operator Limits: Spreading
[...me._items]for massive arrays can hit browser engine limits (especially in Safari/Firefox) and cause stack overflows. - Deep Cloning: Passing the massive
itemsarray directly into the config object causesNeo.core.Baseto deeply clone all 50k items intothis.originalConfigduring instantiation. This takes multiple seconds and causes massive Garbage Collection pauses.
Fix:
Create the allItems collection without the items config to completely bypass the originalConfig deep clone. Then, use me._items.slice() (which avoids spread operator limits while safely shallow-copying) and inject the items via me.allItems.add(), which natively handles internal chunking and stack-overflow protections.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
aibugSomething isn't workingSomething isn't workingperformancePerformance improvements and optimizationsPerformance improvements and optimizations