Skip to content
quarry View Ticket
Login

View Ticket

2026-09-24
00:55 • Ticket [61417e834b] Evaluated valyala/quicktemplate as an html/template replacement — not adopting status still Closed with 1 other change artifact: 116eb08c23 user: zeitgeist
2026-08-31
11:54 • New ticket [61417e834b]. artifact: 3d210fc96a user: ai-local

Evaluated valyala/quicktemplate as an html/template replacement — not adopting

Closed61417e834bebf399d0d2f0a7961da35bcf7563daCreated 91.5 days agoUpdated 67.9 days ago
Description2026-08-31 11:54:08
Asked to look at quicktemplate, which advertises a 20x speedup over html/template. Measured first, and it does not apply to quarry.

WHAT THE BENCHMARK MEASURES: 120ns/op vs html/template 2501ns/op on one simple template. A per-execution microbenchmark, not a page.

WHY IT DOES NOT HELP HERE. The decisive number: /api/v1/r/sqlite/file/trunk/src/btree.c — which never touches html/template — takes 703ms TTFB, SLOWER than the 461ms HTML page for the same file. The cost is blob retrieval and highlighting, not templating. Corroborating: the timeline page emits 309,584 bytes of HTML in 12ms total including ops, so template execution is bounded well under that; scaled linearly, the 2.3MB btree.c page is maybe ~90ms of template inside 461ms. A 20x cut there returns ~19% on one page type and nothing on ordinary pages. Amdahl.

WHAT IT WOULD COST. (1) Escaping: quicktemplate escapes explicitly per tag ({%s%}, {%q%}, {%u%}) — it is NOT contextual. html/template knows whether it is in an attribute, URL, JS or CSS context and escapes accordingly. quarry renders untrusted upstream content — commit messages, ticket titles and forum posts from mirrored fossil repos — so contextual auto-escaping is a security property, and swapping it for per-call discipline across a 20k-line template surface trades a class of XSS bug for percentage points. (2) A qtc codegen step and .qtpl files, where templates are currently Go constants compiled into the binary. (3) A dependency, against the smol contract.

DECISION: no. The measured bottlenecks are highlighting and blob retrieval — see the highlight cache and file-windowing tickets. Revisit only if a profile ever shows template execution dominating, which today it does not.