Typing in a 5,000-row table took 26 seconds per key. Here’s how I got it to 24 ms.
Description and use
Optimizing Sarala reduced keystroke latency in a 5,000‑row table from 26 s to 24 ms by eliminating DOM rebuilds and expensive parsing.
Problem
A single huge table block caused 26 s delay per keystroke in the Sarala editor.
Outcome
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.
Workflow
- 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
Evidence
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.
- Record date: 2026-11-02T21:14:12.582Z