performance / the-memory-pass-of-2026-11-16

performance / the-memory-pass-of-2026-11-16

The memory pass of 2026-11-16

v0.12.0 · 03 / 06 · 2 min read · docs/BENCHMARKS.md

The second optimization pass attacked the cost of reopening what is already

BenchmarkBeforeAfterΔ
cache hit (disk, cached page)2.43 ms0.12 ms~20x
cache put+get170 µs98 µs-42%
extraction, medium article13.9 ms8.2 ms-41%
re-render of a large document12.5 ms4–8 µs~2000x
menu redraw (cache stats)one directory scan per framememoizedno disk I/O per key

What changed:

  1. The session page cache (page_memory.go). The disk cache already made a page you read open in ~2 ms; the new in-memory layer removes the read too, so back and forward do no filesystem work. It is bounded to 24 pages / 24 MB and respects the cache setting.
  2. The rendered-document cache (render_cache.go). renderDoc is the most expensive stage after extraction, and it was repeated for every resize and every return to a page. Rendered documents are now kept in a 12-entry / 48 MB LRU keyed by the Markdown, the width, the layout options and the palette generation; a hit is a map lookup (BenchmarkRenderCached).
  3. A one-pass sanitize. The control-character regexp ran over every page, including every cache hit. It now takes a byte fast path and only rebuilds the string rune by rune when it must.
  4. Memoized cache stats. The menu asked the cache directory for its page and byte counts on every redraw and once per filter entry. The numbers are now refreshed at most every two seconds and invalidated when the cache changes.
  5. Pruning once an hour. cachePut walked the whole cache directory after every saved page; with thousands of pages that is a visible delay on the fetch path. The age-based prune is now throttled to one walk per hour (and reset when the cache is cleared), which keeps the disk bounded without taxing every page load.

edit this page on GitHub ↗report a problem ↗