Typing cost in large files grows with file size outside styling #229

open cmc opened this on 2026-11-22 13:14 UTC · feature · milestone Backlog

Discussion

cmc 2026-11-22 13:14 UTC

After #189 made styling linear, typing p95 in the middle of a large file is unchanged: about 12, 23 and 44 ms at 1, 2 and 4 MB, and 110 ms at 10 MB. Restyling one paragraph in the middle of the 10 MB file takes 3.9 ms, so the cost is elsewhere in OrgEditor.storageEdited.

Candidates that scale with file size: the per-edit mapping of every wrapper fold and shaded block, view.mapped(...).pruned(to:), and updateHidden. Profile and fix. Decide also whether 10 MB is a supported file size.

Related, found in the same work:

  • refreshImages restyles the whole file synchronously (on baseDirectory set with images showing, image or LaTeX toggles, and width changes).
  • In plain (non-org) mode restyle applies highlighter runs for the whole file, not in one pass.
  • With a proportional body font, the fixed-pitch prefix pass starts again from the beginning of each chunk.

Platforms: Mac.