Frontmatter
| id | 9334 |
| title | Performance: Optimize Collection `items_` config to use shallow cloning |
| state | Closed |
| labels | enhancementaiperformance |
| assignees | tobiu |
| createdAt | Feb 27, 2026, 5:34 PM |
| updatedAt | Feb 27, 2026, 6:13 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9334 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Feb 27, 2026, 6:13 PM |
Performance: Optimize Collection items_ config to use shallow cloning
tobiu assigned to @tobiu on Feb 27, 2026, 6:11 PM

tobiu
Feb 27, 2026, 6:11 PM
Input from Gemini 3.1 Pro:
✦ I have resolved this issue.
- We discovered that
Neo.cloneMap.Objectwas being triggered repeatedly for all 50k records and their properties because theitems_config inNeo.collection.Baselacked a clone descriptor, causing it to fall back to the defaultclone: 'deep'mechanism on assignment.- We fixed this by providing a config descriptor for
items_insrc/collection/Base.mjsexplicitly settingclone: 'shallow'. This avoids the expensive full depth clone, performing just[...value]to ensure collection immutability while preserving standard object references for the individual items.- We also fixed a synchronization issue where the initial
afterSetSourceIdhook wasn't updatingme.countafter cloning the source collection data directly.- A performance regression test was created in
test/playwright/unit/app/devindex/StoreFilterProfile.spec.mjswith an explicit assertion to enforce that the initial hydration/filter creation process takes less than 400ms (down from the ~1000ms+ range previously).The issue is resolved and the relevant unit tests all pass!
tobiu closed this issue on Feb 27, 2026, 6:13 PM
Problem
The
items_config inNeo.collection.Basewas defaulting toclone: 'deep'(the default for reactive configs in Neo.mjs). For large datasets (e.g., 50,000 records in the DevIndex app), setting or initializingitems_triggered a deep clone of the entire array and every single record object within it. This caused a massive performance bottleneck, specifically an ~800ms delay when theallItemscollection was created during the first filter operation.Solution
Updated the
items_config to use a descriptor withclone: 'shallow'. This ensures that only the array structure itself is copied (preserving immutability for the collection array) while the individual record objects maintain their exact references. This drops theitemsassignment overhead for 50k records from ~779ms down to ~6ms, eliminating the bottleneck while ensuring updates to records propagate correctly between filtered and unfiltered states.