Skip to content

perf(data-grid): cut reloads, draw work and selection cost on large tables - #4335

Merged
datlechin merged 7 commits into
mainfrom
perf/data-grid-load-and-draw
Nov 19, 2026
Merged

datlechin merged 7 commits into
mainfrom
perf/data-grid-load-and-draw

Conversation

@datlechin

@datlechin datlechin commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

  • P38: a table load reaches the grid as one .reload. reloadRows no longer sends .columnsChanged first, and reloadHeldRows is gone.
  • P38: keys, comments and enum labels arrive as the new Delta.columnMetadataChanged, which keeps the formatted text and reconciles columns only when an accessory moved. An open editor or popover follows that reconcile.
  • P38: configureForTable repaints after a load only when staged rows existed.
  • P39: row numbers draw from a cached CTLine, pixel for pixel where string drawing put them. Cells clip through CGContext.
  • P39: a value wider than its cell keeps its truncated line, and the line cache keys on the 300 units a cell can show.
  • P39: flattening and line break checks scan UTF-8. Per-row reads of the row offset and highlight rules no longer copy the whole tab or rebuild a storage key.
  • P40: GridSelectionSnapshot holds row ids as RowIDRuns, and the selection mirror intersects ranges. repaintAllRows is the new .allRowsRepainted, which rebuilds the marks from the change manager.
  • P41: the prewarm formats 32-row batches off the main actor with its own date renderer. A batch is dropped if cached text changed while it formatted.
  • P42: accessibility stand-ins mount for columns on screen and one each side, plus row numbers, frozen columns and the active cell's column.
  • Rules updated: .claude/rules/data-grid.md, .claude/rules/ui-tests.md.
  • Tests that pinned the old delta, updated on purpose: TableRowsMetadataTests (updateDisplayMetadataStoresComments), TableRowsGeneratedColumnsTests (updateReportsChange), ParseSchemaMetadataTests (the declared types case), SeedBufferFromErrorResultTests.failureUnderAnOpenEditorReconcilesTheGrid (the reload now carries the columns).
  • DataGridCellAppearanceTests.prewarmedTextKeepsTheFormattedFlag now goes through the batch path.
Measured Before After
Column reconciles on a first load, no accessory arriving up to 4 1
Selection step, 1,000,000 rows (snapshot, mirror, watcher) 154.7 ms 7.7 ms
Row number, per draw 36.0 us 1.6 us
Flatten 10,000 Vietnamese characters 325.4 us 20.5 us
Line cache lookup, 10,000 characters 5.96 us 0.50 us
Truncating an overflowing value, per draw 791 ns cached
Prewarm formatting left on the main actor, 500 rows by 20 columns 37.5 ms none, 1.2 ms of bookkeeping
Stand-ins at 200 columns, 28 rows on screen 5,628 224
  • The selection, row number, flatten, line cache and truncation rows come from a Release harness over the real text code and replicas of the rest.
  • The prewarm and stand-in rows come from hosted Debug runs. The prewarm "before" is the same formatting work timed off the main actor.

Test plan

  • Each mechanism reverted in turn fails its test: TableLoadReloadCountTests, DataGridColumnMetadataTests, RowIDRunsTests, DataGridCellTextTests, and the new cases in DataGridModelTests, DataGridDisplayCacheTests, HighlightRuleStorageTests, DataGridAccessibilityMountTests.
  • Unit: 1,106 grid, coordinator and global state cases pass.
  • UI: every suite that finds cells by label passes locally (HeaderSortUITests, DataEditUITests, GridFindUITests, FilterBarReturnUITests, InspectorEditReachesGridUITests, TableChangeReloadUITests, ForeignKeyNavigationUITests, ForeignKeyPickerUITests, TableAutoRefreshUITests, ValueFilterEditUITests, SearchDatabaseUITests, StructureSaveConfirmationUITests).
  • DataEditUITests passed on retry once, during a 16 s app stall while other builds ran, then passed 8 of 8 runs.
  • Not run: VoiceOver by hand.

@datlechin
datlechin enabled auto-merge (squash) November 19, 2026 00:27
@datlechin
datlechin merged commit be1f173 into main Nov 19, 2026
11 of 12 checks passed
@datlechin
datlechin deleted the perf/data-grid-load-and-draw branch November 19, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant