Skip to content

perf(parser): cache KaTeX formula rendering across refreshes#47

Merged
mhersson merged 1 commit into
mainfrom
fix/mpls-008-katex-cache
May 3, 2026
Merged

perf(parser): cache KaTeX formula rendering across refreshes#47
mhersson merged 1 commit into
mainfrom
fix/mpls-008-katex-cache

Conversation

@mhersson
Copy link
Copy Markdown
Owner

@mhersson mhersson commented May 3, 2026

  • Add a process-level cache behind a custom mpls KaTeX extender so identical formulas are not re-rendered through QuickJS on every textDocument/didChange.
  • Mirror the PlantUML cache pattern: sync.RWMutex-guarded map keyed by formula source with an inline/display prefix, "clear half on overflow" eviction, ClearKaTeXCache helper for tests.
  • 7 new tests under -tags cgo cover cache hit/miss, inline/display key separation, bounded eviction, concurrent access (-race), and a parser.HTML() integration test that proves duplicate formulas render exactly once.

Fixes #46.

- Add a process-level cache behind a custom mpls KaTeX extender so identical
  formulas are not re-rendered through QuickJS on every textDocument/didChange.
- Mirror the PlantUML cache pattern: sync.RWMutex-guarded map keyed by
  formula source with an inline/display prefix, "clear half on overflow"
  eviction, ClearKaTeXCache helper for tests.
- 7 new tests under -tags cgo cover cache hit/miss, inline/display key
  separation, bounded eviction, concurrent access (-race), and a
  parser.HTML() integration test that proves duplicate formulas render
  exactly once.

Fixes #46.
@mhersson mhersson merged commit f471b1d into main May 3, 2026
3 checks passed
@mhersson mhersson deleted the fix/mpls-008-katex-cache branch May 4, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KaTeX rendering causes slow refresh

1 participant