Skip to content

Pre-compute footnotes in cached_content on save - #24

Merged
jfi merged 2 commits into
mainfrom
perf/precompute-footnotes-in-cached-content
Mar 24, 2026
Merged

jfi merged 2 commits into
mainfrom
perf/precompute-footnotes-in-cached-content

Conversation

@jfi

@jfi jfi commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • generate_cached_content now stores { "html" => rendered_html, "footnotes" => processed_footnotes } for JSONB columns (BlockContent) instead of plain HTML
  • The Renderer already processes footnotes during rendering but discards the FootnoteRegistry — this captures it
  • TEXT columns (Post) continue to store plain HTML, no behaviour change

Motivation

AppSignal shows p95 transaction_duration spiking above 3s on Panda::CMS::PagesController#show. The RichTextComponent re-parses raw EditorJS JSON on every page view to extract footnotes, even though this data was already computed during generate_cached_content. This eliminates that runtime parsing.

Test plan

  • All 139 panda-editor tests pass
  • All 1085 panda-cms tests pass (862 unit + 223 system)
  • Pair with corresponding panda-cms PR to read the new format

🤖 Generated with Claude Code

The generate_cached_content callback already creates a Renderer with a
FootnoteRegistry and processes all footnotes, but discards the registry
after rendering. On every page view, extract_footnotes_from_content then
re-parses the raw JSON to rebuild this data.

For JSONB columns (BlockContent), cached_content now stores a structured
hash: { "html" => rendered_html, "footnotes" => processed_footnotes }.
For TEXT columns (Post), behaviour is unchanged (plain HTML string).

This eliminates all runtime JSON parsing for display when paired with
the corresponding RichTextComponent changes in panda-cms.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jfi
jfi force-pushed the perf/precompute-footnotes-in-cached-content branch from a8ab610 to a3db3df Compare March 24, 2026 20:07
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jfi
jfi merged commit 4d4657d into main Mar 24, 2026
10 checks passed
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.

1 participant