LearnNewsExamplesConnect
Frontmatter
assigneesneo-gemini-julia
createdAtOct 26, 2026, 2:02 AM
updatedAtOct 26, 2026, 8:48 AM
githubUrlhttps://github.com/neomjs/neo/issues/20115
authorneo-gemini-julia
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 26, 2026, 8:48 AM

Optimize grid.Row, grid.Container, collection.Base, and bigData hot paths

Closed v13.4.0/archive-v13-4-0-chunk-3 enhancementaiperformancecoregrid
neo-gemini-julia
neo-gemini-julia commented on Oct 26, 2026, 2:02 AM

Context

Following the neo.mjs@13.3.1 vs ag-grid-community@36.2.0 (animateRows={false}, vite preview) benchmark update in neomjs/benchmarks#3, a line-by-line V-B-A audit of src/grid/Row.mjs, src/grid/Container.mjs, src/grid/header/Wrapper.mjs, src/collection/Base.mjs, src/data/Store.mjs, and examples/grid/bigData/ surfaced seven concrete hot-path bottlenecks during 100k-row × 200-column dataset swaps, filtering, and 2D virtual scrolling.

  • Live latest-open sweep (ticket-create §1a(i)): Checked latest 20 open issues on neomjs/neo (#20114 down to #19139) at 2026-10-26T01:01:28Z; no equivalent found.
  • A2A in-flight claim sweep (ticket-create §1a(ii)): Checked list_messages({status: 'all', limit: 30}) at 2026-10-26T01:01:14Z; no overlapping [lane-claim] or [lane-intent] on src/grid/*, src/collection/*, or examples/grid/bigData/*.
  • Memory Core & KB rationale sweep (ticket-create §1a(iii)-(iv)): Ran query_raw_memories (grid Row createVdom permanent columns collection splice isFilteredItem evaluateFilters bigData performance), ask_knowledge_base, and gh issue list --state open --assignee @me (0 open issues); no prior retraction or duplicate found.

The Problem

  1. Unconditional O(rows × totalColumns) Pass-2 permanent-column loop in Neo.grid.Row#createVdom (src/grid/Row.mjs:564-588): On every vertical or horizontal scroll frame and every store load, Pass 2 executes for (i = 0; i < countColumns; i++) on every visible row, calling columnPositions.getAt(i) and columns.get(columnPosition.dataField) 200 times per row (30 rows × 200 columns = 6,000 lookups per frame) to check if (column.hideMode !== 'removeDom' || column.locked) — even when zero columns in the grid use permanent mode or locking.
  2. Non-silent clear() + add() inside Neo.grid.Container#createColumns (src/grid/Container.mjs:962-973) and leaked header.Button instances in Neo.grid.header.Wrapper#updateHeaders (src/grid/header/Wrapper.mjs:216-239): When grid.columns = newColumns is assigned at runtime (me._columns is already a Collection with listeners: {mutate: me.onColumnsMutate}), line 963 calls me._columns.clear() (firing onColumnsMutate #1 with 0 columns, running createOrUpdateSubGrids() and a passSizeToBody() main-thread getLayoutRect IPC round-trip), line 964 calls me._columns.add(columns) (firing onColumnsMutate #2, running a second createOrUpdateSubGrids(), second passSizeToBody() IPC round-trip, and applyColumnButtonOrder() across 200 columns), and line 970 then calls me.createOrUpdateSubGrids(lockedStartButtons, centerButtons, lockedEndButtons) a third time. Furthermore, Wrapper#updateHeaders overwrites headerToolbar.items = centerButtons without destroying the previous Neo.grid.header.Button instances.
  3. Redundant render passes in examples/grid/bigData/GridContainer.mjs (lines 78-80) and MainStore.mjs (lines 93-129): GridContainer#afterSetAmountColumns sets this.store.amountColumns = value before this.columns = columns, causing GridBody to render the newly generated 200-column records against the old 50 columns before rebuilding the 200 columns. In addition, MainStore calls me.clear(false) followed by me.add(data, false), firing two separate mutate → load cycles (the first rendering an empty grid and arming a 50ms scrollTo timer).
  4. 100,000 isFilteredItem invocations during bulk Collection#splice when no filter is effective (src/collection/Base.mjs:1597-1630, src/data/Store.mjs:1091-1107): MainStore configures two inactive filters (firstname: null, lastname: null). During store.add(data, false) for 100,000 items, Collection#splice calls !me.isFilteredItem(item) 100,000 times (Store#isFilteredItem iterating me.filters.forEach 100,000 times and Collection#isFilteredItem calling Filter#isFiltered 200,000 times) even though me._filters.some(f => f.effective) is false.
  5. Unconditional items.slice() of 100,000 items in Collection#evaluateFilters (src/collection/Base.mjs:1161): let filtered = items.slice() clones the 100,000-element array unconditionally right before if (this.filterMode === 'primitive') { filtered = []; } discards the clone.
  6. Per-cell getLogicalCellId string allocation and selectedCells.includes() in Row#applyRendererOutput (src/grid/Row.mjs:302, 467): Because selectedCells defaults to [] (Row.mjs:422), if (selectedCells) is always truthy, allocating logicalCellId and calling .includes() on every rendered cell even when selectedCells.length === 0.

The Architectural Reality

  • Neo.collection.Filter already exposes a canonical get effective() getter (src/collection/Filter.mjs:115-118: !me.disabled && (!!me.filterBy || !(me.includeEmptyValues && (me.value === null || Neo.isEmpty(me.value))))).
  • Neo.grid.Container#onColumnLockChange (src/grid/Container.mjs:1209) already uses clearSilent() to avoid double-firing onColumnsMutate.

The Fix

  1. src/grid/Row.mjs & src/grid/Body.mjs:
    • Guard Pass 2 in Row#createVdom so it only iterates when the grid has permanent (hideMode !== 'removeDom') or locked columns (or iterate a pre-filtered list of permanent column indices).
    • Guard if (selectedCells?.length > 0) (at Row.mjs:302) and if (selectedRows?.length > 0 && record) (at Row.mjs:467) before computing logicalCellId or calling .includes().
  2. src/grid/Container.mjs & src/grid/header/Wrapper.mjs:
    • In Container#createColumns (src/grid/Container.mjs:962-973), destroy replaced column instances and update me._columns without triggering two premature onColumnsMutate passes before createOrUpdateSubGrids(lockedStartButtons, centerButtons, lockedEndButtons).
    • In Wrapper#updateHeaders (src/grid/header/Wrapper.mjs:216-239), destroy replaced Neo.grid.header.Button instances before assigning new button configs to items and calling createItems().
  3. src/collection/Base.mjs & src/data/Store.mjs:
    • In Collection#splice (src/collection/Base.mjs:1597-1630), compute const hasEffectiveFilters = me._filters.some(f => f.effective) once before the for (i = 0; i < len; i++) loop and only call me.isFilteredItem(item) when hasEffectiveFilters is true.
    • In Collection#evaluateFilters (src/collection/Base.mjs:1161), only call items.slice() in the non-primitive branch.
  4. examples/grid/bigData/GridContainer.mjs & MainStore.mjs:
    • Use me.clearSilent() (and me.allItems?.clearSilent()) before me.add(data, false) in MainStore so dataset swaps emit a single mutate → load event.
    • Coordinate GridContainer#afterSetAmountColumns so column definitions and store data update without rendering the new dataset against stale columns first.

Decision Record impact

none — preserves all existing Neo.grid, Neo.collection, and Neo.data.Store contracts and event semantics while eliminating redundant work in hot paths.

Acceptance Criteria

  • Neo.grid.Row#createVdom skips Pass 2's O(countColumns) loop when no column has hideMode !== 'removeDom' or locked, while preserving permanent/locked cell rendering when present.
  • Neo.grid.Row#applyRendererOutput and createVdom skip getLogicalCellId and .includes() when selectedCells / selectedRows is empty.
  • Neo.grid.Container#createColumns and Neo.grid.header.Wrapper#updateHeaders avoid redundant onColumnsMutate passes and destroy replaced column / header button instances on runtime grid.columns = ... reassignment.
  • Neo.collection.Base#splice checks me._filters.some(f => f.effective) once before the item loop, skipping per-item isFilteredItem calls when no filter is effective.
  • Neo.collection.Base#evaluateFilters avoids cloning items.slice() when this.filterMode === 'primitive'.
  • examples/grid/bigData/GridContainer.mjs and MainStore.mjs avoid redundant intermediate clear(false) and stale-column render passes on row/column count changes.
  • Existing grid, collection, and store Playwright unit tests pass (npx playwright test --config buildScripts/playwright/playwright.config.unit.mjs).

Out of Scope

  • Changing Neo.data.Store#initialChunkSize defaults globally.
  • Benchmark suite changes in neomjs/benchmarks (tracked separately in neomjs/benchmarks).

Related

Origin Session ID: 74232d92-30de-45ab-ab3d-4579227f3b4b Retrieval Hint: "Optimize grid.Row grid.Container collection.Base bigData hot paths Pass 2 permanent columns Filter effective"

tobiu referenced in commit 056f549 - "fix(grid,collection): optimize Row, Container, Collection, and bigData hot paths (#20115) (#20116) on Oct 26, 2026, 8:48 AM
tobiu closed this issue on Oct 26, 2026, 8:48 AM