Gingham 1.2SwiftAppKitUIKitSwiftUI
I needed a Mac table for a million live rows, so I wrote one
A fast table view for business data on the Mac, iPad and iPhone: NSTableView’s API, drawn by the GPU, free up to 10,000 rows a table.
- Live order book, 200,000 rows 120fps 36% main thread · 1.8 W Fastest NSTableView: 80 · 95% · 4.6 W
- 1,000,000 rows sorted by text 0.19s the first sort, in Finder’s order NSTableView: about 8 s
- iPhone, 1,000,000 rows while scrolling 120fps 26% main thread Well-written UIKit tables: 120 · about 41%
Free up to 10,000 rows a table. More rows: a key per developer, $199 or $599 for all of 1.x, no subscription. Pricing
- 0:00 Gingham
- 0:06 NSTableView, as typically written
- 0:12 NSTableView, cell-based, tuned
- 0:18 SwiftUI Table, rows by position
I build in-house tools for performance marketing. While writing a Swift desktop client for our ad-campaign platform, I hit the wall every Mac developer with big data hits. Its screens are tables — campaigns, ad placements, offers, stats — with hundreds of thousands of rows whose numbers change all the time, and people sort, filter and total across all of them.
As the data grew, the tables started to stutter, both SwiftUI’s Table and NSTableView. The usual advice is pagination. That doesn’t work when someone sorts 200,000 placements by ROI to see the worst ones, or wants the total spend of everything a filter leaves.
So I wrote my own table. It’s called Gingham, and it runs on the Mac, iPad and iPhone.
Measured in the open#
Numbers from the author of a library are worth little. So the benchmark is open: Gingham Bench (MIT) contains:
- the code of every table it compares;
- the data;
- how each number is measured;
- a notarized app you can run on your own Mac, and the iPhone and iPad app on TestFlight.
Gingham is used through its public API. It competes against Apple’s tables written several ways:
- NSTableView, as apps typically write it: the app sorts all rows again after each batch of changes and reloads the rows in view;
- NSTableView tuned as an AppKit expert might: cells updated in place, numbers formatted by hand, an incremental sort;
- NSTableView in its cell-based mode, tuned the same way;
- NSCollectionView, tuned the same way;
- SwiftUI’s Table: as documented, tuned, and with rows identified by their position.
I wrote the competitors’ code too, as well as I could, and nobody else has reviewed it yet. If you can make any of them faster, open a pull request, and it will be measured and published, whatever it does to Gingham’s lead.
The headline#
A live order book: 200,000 rows, about 243,500 row changes a second, rows added and removed, in a 2040 × 1080-point window. MacBook Pro M1 Max, built-in 120 Hz display, Gingham 1.2.0, Release builds, median of 3 runs; every cell was measured on two nights, 97% of the 1,127 numbers agree within 10%, and Gingham’s row below is the same on both. “Power” is what the whole Mac’s CPU and GPU drew, from powermetrics (the window server’s compositing included; not the display or memory).
A live order book, 200,000 rows
About 243,500 row changes a second · 2040 × 1080-point window · median of 3 runs
| Table | Updates a second (max 120) | Main thread busy | Power |
|---|---|---|---|
| Gingham | 120 | ||
| NSTableView, cell-based, tuned | 80 | ||
| NSCollectionView, tuned | 34 | ||
| NSTableView, tuned | 33 | ||
| SwiftUI Table, rows by position | 18 | ||
| NSTableView, as typically written | 10 | ||
| SwiftUI Table, as documented and tuned | stuck | — | — |
For Gingham the figure is the frames it presented; for the others, the updates they applied. The marks are spread evenly over one second, one per update, and a playhead crosses them in real time. Bars are to scale: the main thread to 100%, power to 5 W.
MacBook Pro (M1 Max, 32 GB) · macOS 27.2.1 · built-in display at 120 Hz · Gingham 1.2.0 · Release builds · medians of 3 runs · 2026-11-26 · results/2026-11-26-0255.md
I measured power as well as frames. A table that keeps up but drains the battery hasn’t really solved the problem. Per update, Gingham spends about 15 mJ here; the AppKit tables spend 57–392 mJ.
The other scenarios hold up the same way:
-
A trade feed of 1,000,000 rows with about 300,000 changes a second (the same window): Gingham presents 120 frames a second with its main thread 39% busy. The tuned cell-based NSTableView applies 45 updates a second; the typical NSTableView applies 4.
-
At an equal 30 updates a second, what an app would throttle to (the same window): Gingham keeps 21–24% of the main thread busy and the Mac draws 0.44–0.96 W; the tuned cell-based NSTableView, the only other table that holds 30 in every scenario, 35–71% and 1.16–3.40 W.
-
Sorting a million rows by a column of nearly unique texts (the first sort, in Finder’s order):
- Gingham takes 0.19 s.
- NSTableView takes about 8 s, tuned or not. The typical one freezes the app for all of it; the tuned ones sort in the background and keep their keys, so sorting by that column again is fast.
- SwiftUI’s Table, as documented, didn’t finish within a minute; tuned, it took 13–14 s.
-
On the iPhone (15 Pro Max), 1,000,000 rows with 10,000 changes a second, while scrolling: Gingham holds 120 frames a second with its main thread 26% busy. Well-written UIKit tables and SwiftUI’s List keep up too, at about 41%; a typical UITableView manages 7.
Sorting 1,000,000 rows by text
A column of nearly unique texts, in Finder’s order · time to the first frame that shows the new order · median of 3 runs
| Table | The first sort | The same column again |
|---|---|---|
| Gingham | 0.02 s | |
| NSTableView, cell-based, tuned | 0.07 s | |
| NSCollectionView, tuned | 0.06 s | |
| NSTableView, tuned | 0.16 s | |
| NSTableView, as typically writtenthe app frozen meanwhile | 7.97 s | |
| SwiftUI Table, tuned | 0.91 s | |
| SwiftUI Table, rows by position | 1.36 s | |
| SwiftUI Table, as documented | didn’t finish |
Bars to 14 s. SwiftUI’s Table as documented didn’t show the sorted rows within 60 s. The tuned tables keep the keys of the columns they sorted last, so sorting by one again is fast; the typical one sorts from scratch.
The same Mac · default 1000 × 640-point window · Gingham 1.2.0 · Release builds · medians of 3 runs · 2026-11-26 · results/2026-11-26-0025.md
Where Gingham isn’t ahead#
The bench shows these cases where Gingham loses or ties:
-
In the default 1000 × 640 window, the tuned cell-based NSTableView also keeps up with every change, though its main thread is busier and the Mac draws more power.
-
On a quiet table (5,000 rows, 10 changes a second), the tuned AppKit tables cost less: 2% of the main thread against Gingham’s 5%.
-
Scrolling 100,000 rows, the cell-based NSTableView keeps its main thread less busy (40% against 57%), though the Mac draws more power with it.
-
Memory: Gingham’s footprint is larger than the view-based tables’.
-
Power on very large tables: on a 3840 × 2160-point table on the MacBook’s own display, Gingham draws more power than AppKit in two scenarios. It does show 120 frames a second there, where AppKit manages 2–21 updates; on a real 4K monitor at 60 Hz it draws less than AppKit in all four.
The full list is in the bench’s README.
Why the stock tables fall behind#
The stock tables don’t have to be badly written for this to happen:
The typical way
The app sorts again after every batch of changes, and the table reloads what’s in view. At hundreds of thousands of changes a second, that alone eats the main thread.
The tuned way
It avoids the re-sorting, but every visible change still goes through AppKit’s views or cells on the main thread.
Gingham does it differently
- It keeps the order live itself, touching only the rows that changed.
- The GPU draws the table.
- For huge data, sorting, search and totals run on all cores, off the main thread.
Not only fast#
A fast table that does nothing is easy. Gingham does what business apps need:
- Columns: frozen at either edge, and column groups under a shared header.
- Summary row: sums, averages, counts and formulas over other columns, such as ROI as a ratio of sums.
- Row grouping: with subtotals, several levels deep.
- Search and filters: that hide rows without touching your data source.
- Row identity: the selection stays on the same records through sorts and reloads.
- Cell types: tags, sparklines, progress bars, ratings, links, buttons, pictures and videos.
- Platform behaviour: keyboard navigation, type select, copying to spreadsheets and VoiceOver, and right-to-left layout. On the iPad and iPhone: touch, the pointer and a hardware keyboard.
The API mirrors NSTableView: the same data source, delegate, sort descriptors and notification names. On the Mac it also comes with an adapter for an existing NSTableViewDataSource. In SwiftUI on the Mac, GHDataTable works like Table:
GHDataTable(campaigns, selection: $selection) {
GHDataColumn("Name", value: \.name)
GHDataColumn("Spend", value: \.spend, format: .currency(code: "USD"), summary: .aggregate(.sum))
}
A side quest: sorting text like Finder, without ICU#
People expect text sorted the way Finder sorts it. In Swift that means localizedStandardCompare, and calling it millions of times is slow.
Gingham sorts text by its own keys instead, made for the user’s language and checked against Foundation’s order. They cover:
- Every European language
- Cyrillic
- Greek
- Hebrew
- Arabic
- Devanagari
- Kana
- Han
- Hangul
A million texts sort in about 0.2 seconds in the background, in localizedStandardCompare’s order: checked against Foundation on millions of pairs in 26 languages. Where Foundation’s own comparison contradicts itself (some capitals with Ё, for one), Gingham keeps one consistent order. An optional ICU module covers Thai and the trickier Chinese cases.
A real app on top of it#
Granule for ClickHouse is a free ClickHouse client for the Mac, iPad and iPhone, built on Gingham, and its source is open. Results of tens of millions of rows scroll, sort and search without freezing.
Try it#
.package(url: "https://github.com/digitalglobeby/Gingham", from: "1.2.1")
- Requirements: macOS 14+ on Apple silicon (like macOS 27, no Intel); iOS and iPadOS 17+; Swift 6.2, Xcode 26.
- Free for any use, commercial too, up to 10,000 rows a table. Open-source apps get a key for free, and there’s a 30-day trial key with every row.
- More rows need a license key, per developer, covering a whole major version (all of 1.x); apps shipped with it stay licensed, no subscription and no runtime fees:
- Indie, $199: a solo developer or a company with less than $250,000 a year in revenue;
- Business, $599;
- Enterprise, by agreement: priority support and the source in escrow.
- Package and issues
- github.com/digitalglobeby/Gingham