View as Markdown

Performance

Performance

What the grid re-renders, how to observe it in development, and the budgets that gate every release.

Performance comes first in Salmon UI: every performance budget is a release gate, asserted on a developer or reference machine by npm run release:verify (there is no hosted CI), and a behavior that cannot meet one ships opt-in or not at all. Virtualization, scaled scrolling and the server-rendered range are on the virtualization page; this page covers what one interaction re-renders.

Compiled columns

Columns compile once per stable definition identity (Structural Budgets, "Column compile count for a stable columns prop identity": 1 for the component lifetime). Keep columns at module scope or in a memo: a parent re-render then passes the same identity, and the grid re-renders no header and no cell. Reactive fields (hidden, numeric width, pinned, order) are applied as runtime state when they change, and a changed definition recompiles only that column. The compile count itself is gated by the core unit test that reads engine.getInstrumentation() (createDataGridEngine({ instrument: true })); on DataGrid, the initial-only instrument prop does the same (api.engine.getInstrumentation()), and leaving it off costs nothing.

One million local rows

A data array of 1,000,000 rows needs no special mode. Two budgets gate it: the client mount to the first painted viewport of the 1M × 20 million fixture takes at most 500 ms in a production build, and engine creation plus the first viewport read at most 500 ms and 10 ms. Rows are never copied or wrapped, and only the rendered window is read. The One million rows demo on the virtualization page mounts that data set and scrolls it end to end.

Selection and focus

Data Grid state lives in the core engine store; React components subscribe to narrow slices. Moving the focus re-renders at most the old and the new cell (the demo's arrow-key moves commit nothing at all), and toggling one row's selection re-renders that row's cells plus the select-all header cell, never the rest of the grid (Structural Budgets, "Cells re-rendered on focus move" ≤ 2 and "Cells re-rendered on single-row selection toggle"). The selection toggle itself is O(1) in the core (Timing Budgets, Interaction).

What a grid downloads

A grid downloads only the features its props turn on. A plain <DataGrid data columns /> loads the base grid (rendering, virtualization, sorting, filtering, selection, keyboard), which the Minimal app budget (Bundle Budgets) caps at 110 KB gzip of initial JS with React and React DOM excluded. Setting grouping, paging, search, toolbar, aggregates, renderDetail or childGrid, a lookup column, and the other feature props loads that feature's code on demand; each one has its own size budget.

  • Server rendering is unchanged: the server has every feature's code, so the HTML is complete, and hydration keeps it on screen until the browser has loaded the features it needs.
  • A grid rendered only in the browser shows a placeholder of its own size (aria-busy) for that one download.
  • Editors, menus, dialogs, export and print load later, on first use.

To skip the wait, pass the features to the optional features prop. It bundles them with your page; it does not enable anything, so the feature props are still required:

import { grouping, paging } from '@salmonui/data-grid/features';

<DataGrid data={orders} columns={columns} grouping paging features={[grouping, paging]} />;

Leaving features out never disables a feature; the feature's code is then loaded on demand instead.

Observing renders in development

Development builds call globalThis.__SALMON_UI_DEVTOOLS__.onCommit(commit) after every grid commit with the re-rendered cell, row and header ids (DataGridDevtoolsCommit); production builds never reference the hook. The demo installs it in an effect and shows the totals since the last reset in a separate component, so counting never re-renders the grid.

Render counts

Open demo

The dev-only __SALMON_UI_DEVTOOLS__ hook counts what each interaction re-renders - nothing for a parent re-render with stable columns, only the touched cells for focus and selection.

Order
Customer
Country
Product
Amount
ORD-10000
Bao Nguyen
Germany
Kettle
$220.66
ORD-10001
Ines Duarte
Germany
Grinder
$735.30
ORD-10002
Bao Nguyen
Japan
Espresso beans
$16.65
ORD-10003
Jun Park
Germany
Espresso beans
$141.53
ORD-10004
Dewi Lestari
Germany
Green tea
$55.04
ORD-10005
Bao Nguyen
Germany
Kettle
$292.05
ORD-10006
Jun Park
Portugal
Filter beans
$146.30
ORD-10007
Elif Kaya
Malaysia
Pour-over kit
$168.00
ORD-10008
Bao Nguyen
Japan
Green tea
$17.58
ORD-10009
Aiko Tan
Malaysia
Grinder
$1,470.60
ORD-10010
Dewi Lestari
Portugal
Green tea
$70.76
ORD-10011
Jun Park
Japan
Kettle
$233.64
ORD-10012
Elif Kaya
Japan
Filter beans
$100.80
ORD-10013
Chen Wei
Japan
Green tea
$64.75
ORD-10014
Farah Aziz
France
Filter beans
$95.20
ORD-10015
Ines Duarte
Japan
Espresso beans
$141.53
ORD-10016
Jun Park
France
Filter beans
$70.00
ORD-10017
Aiko Tan
Portugal
Green tea
$70.76
ORD-10018
Chen Wei
Japan
Green tea
$87.88
ORD-10019
Bao Nguyen
France
Green tea
$64.75

Since reset: 0 grid commits, 0 cells, 0 rows, 0 header cells re-rendered.

API

instrument, recordCommands and features are on DataGridProps; the feature values come from @salmonui/data-grid/features.