Motivation
When a grid with a very large number of rows (e.g., 100,000) has its store cleared via store.removeAll() or by loading an empty dataset, the standard update() process introduces a noticeable performance overhead.
The createViewData() method is fast in this scenario, as it has no new rows to generate. However, the subsequent me.update() call triggers a full VDOM diff between the 100,000 existing rows and the new empty state. While Neo's diffing algorithm is highly optimized, this is still a significant and unnecessary amount of work.
Initial benchmarks showed that clearing a 100k row grid took ~13ms. While this is within a single frame, it's an overhead that can be completely avoided. The goal is to make this operation near-instantaneous.
Implementation
A "fast path" was added to the grid.Body#onStoreLoad() method to specifically handle this scenario.
The logic is as follows:
- Check if the incoming
data from the load event is empty (data?.length < 1).
- If it is, and if the grid body currently has rows, it bypasses the standard
createViewData() and update() calls entirely.
- It directly clears the internal VDOM array:
vdomRoot.cn = [].
- It clears the VNode cache:
me.getVnodeRoot().childNodes = [].
- It sends a single, direct delta to the main thread to clear the real DOM:
Neo.applyDeltas({id: vdomRoot.id, textContent: ''}).
A descriptive comment was also added to the code to explain the rationale behind this optimization.
Benefits
- Drastic Performance Improvement: Reduces the time to clear a large grid from ~13ms to a negligible amount, making the UI feel instantaneous.
- Reduced CPU Load: Avoids a large, unnecessary VDOM diffing operation.
- Improved Code Efficiency: Handles a common, specific use case with a highly optimized, targeted solution.
Motivation
When a grid with a very large number of rows (e.g., 100,000) has its store cleared via
store.removeAll()or by loading an empty dataset, the standardupdate()process introduces a noticeable performance overhead.The
createViewData()method is fast in this scenario, as it has no new rows to generate. However, the subsequentme.update()call triggers a full VDOM diff between the 100,000 existing rows and the new empty state. While Neo's diffing algorithm is highly optimized, this is still a significant and unnecessary amount of work.Initial benchmarks showed that clearing a 100k row grid took ~13ms. While this is within a single frame, it's an overhead that can be completely avoided. The goal is to make this operation near-instantaneous.
Implementation
A "fast path" was added to the
grid.Body#onStoreLoad()method to specifically handle this scenario.The logic is as follows:
datafrom theloadevent is empty (data?.length < 1).createViewData()andupdate()calls entirely.vdomRoot.cn = [].me.getVnodeRoot().childNodes = [].Neo.applyDeltas({id: vdomRoot.id, textContent: ''}).A descriptive comment was also added to the code to explain the rationale behind this optimization.
Benefits