Docs native S1b: the numbers
Step 0's cause and the before/after table in native/benchmarks/README.md.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+50
−0
native/benchmarks/README.md+50 −0
diff --git a/native/benchmarks/README.md b/native/benchmarks/README.md| index 927cd32..0937a37 100644 |
| --- a/native/benchmarks/README.md |
| +++ b/native/benchmarks/README.md |
| @@ -160,3 +160,53 @@ main thread's busy time per peer change, which also counts the network, |
| the replica's answer and drawing, p20 is 23 ms. The Mac paged keyDown |
| and stall targets wait for S1b, as the plan says: `updatePagination` |
| still copies and measures the whole document per storage edit. |
| + |
| +## S1b: incremental pagination and the keystroke path (2026-11-26, `perf/native-s1b`) |
| + |
| +Same probes and machine as S1a, with step 0's additions: "keyDown to |
| +drawn" is the key and then the window's layout and display pass, run at |
| +once (event → text storage → layout → display; the text's own drawing |
| +happens at the transaction commit after it, about 0.2 ms); the display |
| +pass is also timed alone; line requests are TextKit's, counted inside the |
| +containers. A is main plus the probes (`facc40e`), B the branch. The load |
| +average was 150–600 throughout (other agents' builds), so timings are |
| +indicative and the counters exact. p20 and p200h are three interleaved |
| +runs each (A then B, per row; medians); the other rows are single runs. |
| + |
| +**Step 0, the cause.** Paged, two passes of `updatePagination` per key |
| +copied and laid out the whole document (36 ms at p20) and `layout()` laid |
| +out the whole live container (29 ms): 759 line requests a key at p20, |
| +7,694 at p200h, to each of the live and the measurement containers. |
| +Pageless, `layout()`'s whole-container layout cost 6–9 ms a key at |
| +p200h. Outside pagination, the display pass after every key spent about |
| +3 ms in SwiftUI's hosting views (the workspace, the Format inspector and |
| +the menus read state that moves twice a key), and the toolbar's state, |
| +refreshed five times a key, walked the whole projection (0.5 ms a |
| +refresh at p200h). A third of `keyDown` under this load is AppKit hiding |
| +the cursor (`SLSObscureCursor`, a WindowServer round trip): the system's. |
| +At p200h paged every page label (200) was drawn on every frame. |
| + |
| +| Mac, 40 keys at 8/s | p1 | p5 | p20 | p50 | p200h | |
| +|---|---|---|---|---|---| |
| +| keyDown, paged | 3.7 → 1.9 ms | 17.7 → 2.1 ms | 66.3 → 2.4 ms | 179 → 2.4 ms | 680 → 3.4 ms | |
| +| keyDown to drawn, paged | 6.8 → 2.0 ms | 21.2 → 2.1 ms | 69.5 → 2.5 ms | 182 → 2.5 ms | 683 → 3.5 ms | |
| +| keyDown, pageless | 1.3 → 1.4 ms | 1.3 → 2.1 ms | 1.7 → 2.6 ms | 2.1 → 3.9 ms | 8.7 → 2.6 ms | |
| +| keyDown to drawn, pageless | 4.5 → 1.4 ms | 4.6 → 2.1 ms | 4.8 → 2.7 ms | 5.5 → 3.9 ms | 12.1 → 2.7 ms | |
| +| Line requests per key, live (paged) | 6 → 5 | 195 → 5 | 759 → 6 | 1,895 → 9 | 7,694 → 6 (max 21) | |
| +| Stalls > 16.7 ms, paged | 0 → 0 | 40 → 0 | 40 → 0 | (one 7 s block) → 0 | (one 27 s block) → 0 | |
| +| Stalls > 16.7 ms, pageless | 0 → 0 | 0 → 0 | 0 → 0 | 1 → 1 | 10, 1, 1 → 0, 1, 0 | |
| + |
| +The display pass after a key: 3.1–4.1 → 0.05 ms everywhere. p20 over 200 |
| +keys: paged median 1.8 ms, p95 2.4 ms; pageless 1.7 / 2.0 ms. Per peer |
| +change, all main-thread busy: paged p20 94 → 32 ms, p200h 315 → 39 ms; |
| +pageless unchanged (30 → 32, 47 → 42 ms). Pages off or on at the end of |
| +a 200-page document (unit test, load 450–600): 0.50–0.63 s, the live |
| +layout laid out again from the first break to the visible end (8,500 |
| +lines; the live container is laid out contiguously, the §7 fallback). |
| + |
| +**iPhone (simulator, DocsKit Debug; `SurfaceTimingTests.testKeystroke`).** |
| +Unchanged by S1b, and the spec's plan for it does not hold (see the |
| +discussion): per key median 1.3–2.7 ms, but a key that changes a line |
| +count lays the rest of the document out again inside UIKit's TextKit 1 |
| +(max 59 → 10,454 line requests, 4 ms at p1 to 250–440 ms at p200h), and |
| +opening p200h lays all of it out (0.6–3.2 s). |