Typing in a 5,000-row table took 26 seconds per key. Here’s how I got it to 24 ms.
说明与用途
通过消除 DOM 重建和昂贵的解析,Sarala 编辑器将 5,000 行表格的键入延迟从 26 秒降至 24 毫秒。
问题
A single huge table block caused 26 s delay per keystroke in the Sarala editor.
结果
Optimized Sarala’s handling of large blocks by eliminating DOM rebuilds and expensive parsing, reducing keystroke latency from 26 s to 24 ms for a 5,000‑row table.
工作流
- Benchmark large documents in browser
- Profile keystroke latency
- Identify DOM layout cost
- Detect three bugs: table re‑measurement, quadratic token walk, per‑character slice
- Replace block rendering with line‑by‑line editing
- Use inline spans for layout
- Add correctness tests for cursor behavior
- Measure performance again
- Publish results
证据
A 5,000-row table took 26,028 ms per key
The big change: a very long block now edits as plain lines while it's active
My first profile didn't add up. Three keys took about 1.9 seconds, but JavaScript accounted for only around 500 ms.
- 记录日期: 2026-11-02T21:14:12.582Z