Skip to content
quarry View Ticket
Login

View Ticket

2026-09-24
00:55 • Ticket [073e11ce05] Size-gate the syntax highlighter: plain text past a threshold status still Closed with 1 other change artifact: 334550526b user: zeitgeist
2026-08-31
15:32 • Closed ticket [073e11ce05]. artifact: 09ce4dcb49 user: ai-local
12:12 • New ticket [073e11ce05]. artifact: 8edee5e56e user: ai-local

Size-gate the syntax highlighter: plain text past a threshold

Closed073e11ce0566ae41edd6f8515773081afbcd54a9Created 91.5 days agoUpdated 67.9 days ago
Description2026-08-31 12:12:18
highlight.Code has no size gate — every byte of every file is tokenised on every request, with no cache.

The cost tracks TOKEN DENSITY, not file size, which is the tell: src/sqlite.h.in is the largest file at 559KB but the fastest at 208ms (mostly doc comments), while src/btree.c is 407KB of dense C at 490ms and select.c 337KB at 474ms. Highlighting dominates, not blob retrieval.

Past a threshold, skip the lexer and emit a plain

. Chroma emits a span per token, so this removes both the render cost and most of the 5.7x HTML blowup (btree.c: 407KB source becomes 2,335,223 bytes of HTML). GitHub does exactly this for large files, so the degradation is a known, expected one.

This is the cheapest large-file fix and the only one that helps the FIRST view — a cache cannot. It is complementary to the highlight cache (9e53a2d9) and is subsumed later by windowing (a82ff129), which highlights only the visible window.

Acceptance: a file past the threshold renders in well under 100ms as plain text with a visible notice saying why; below the threshold nothing changes; the threshold is one named constant.

2026-08-31 15:32:22

Landed in f4e226e5 then deliberately narrowed in 937b10d6. At 256KB it turned ten of sqlite's src files permanently grey, which trades the feature for the fix — the owner was right to push back. Now a 2MB safety valve that no real file hits; windowing (a82ff129) removed the need for a threshold at all. Vestigial and removable.