Skip to content

[stable34] perf(editor): only serialize markdown on update when it is read - #9543

Merged
mejo- merged 1 commit into
stable34from
backport/stable34/9525
Nov 5, 2026
Merged

mejo- merged 1 commit into
stable34from
backport/stable34/9525

Conversation

@mejo-

@mejo- mejo- commented Nov 4, 2026

Copy link
Copy Markdown
Member

CollaborativeEditor serialized the whole document to markdown on every editor update to emit update:content, even when no listener uses the result. On large documents this blocks every keystroke, especially in Chromium where prosemirror-markdown's serializer is quadratic in the output size.

Emit the markdown as a getter so it is only serialized when a listener reads it.

Benchmark on a 500 kB markdown document (headings, paragraphs, lists with marks), headless browsers against a local instance, median per step, before -> after:

Chromium:

  • typing (cursor at start): 981 ms -> 67 ms
  • typing (cursor at end): 933 ms -> 34 ms
  • toggle bold on a word: 930 ms -> 50 ms
  • editor update handlers: ~870 ms -> <1 ms

Firefox:

  • typing (cursor at start): 125 ms -> 76 ms
  • typing (cursor at end): 55 ms -> 47 ms
  • toggle bold on a word: 67 ms -> 88 ms (within noise)
  • editor update handlers: ~9 ms -> 1 ms

Large tables are not affected by this change; their cost lies elsewhere.

Related to #908

Assisted-by: ClaudeCode:claude-opus-5-5

🏁 Checklist

  • Code is properly formatted (npm run lint / npm run stylelint / composer run cs:check)
  • Sign-off message is added to all commits

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI tools
  • The AI-generated content was reviewed, comprehended and tested by a human

@mejo- mejo- self-assigned this Nov 4, 2026
@mejo- mejo- added bug Something isn't working 3. to review performance 🚀 labels Nov 4, 2026
@github-project-automation github-project-automation Bot moved this to 🧭 Planning evaluation (don't pick) in 📝 Productivity team Nov 4, 2026
@mejo- mejo- moved this from 🧭 Planning evaluation (don't pick) to 👀 In review in 📝 Productivity team Nov 4, 2026
@mejo-
mejo- force-pushed the backport/stable34/9525 branch from af0a9c6 to 34c76a8 Compare November 4, 2026 16:39
@mejo-

mejo- commented Nov 4, 2026

Copy link
Copy Markdown
Member Author

/backport! to stable33

CollaborativeEditor serialized the whole document to markdown on every
editor update to emit `update:content`, even when no listener uses the
result. On large documents this blocks every keystroke, especially in
Chromium where prosemirror-markdown's serializer is quadratic in the
output size.

Emit the markdown as a getter so it is only serialized when a listener
reads it.

Benchmark on a 500 kB markdown document (headings, paragraphs, lists
with marks), headless browsers against a local instance, median per
step, before -> after:

Chromium:
- typing (cursor at start):  981 ms -> 67 ms
- typing (cursor at end):    933 ms -> 34 ms
- toggle bold on a word:     930 ms -> 50 ms
- editor update handlers:    ~870 ms -> <1 ms

Firefox:
- typing (cursor at start):  125 ms -> 76 ms
- typing (cursor at end):     55 ms -> 47 ms
- toggle bold on a word:      67 ms -> 88 ms (within noise)
- editor update handlers:     ~9 ms -> 1 ms

Large tables are not affected by this change; their cost lies elsewhere.

Related to #908

Signed-off-by: Jonas <jonas@freesources.org>
Assisted-by: ClaudeCode:claude-opus-5-5
@mejo-
mejo- force-pushed the backport/stable34/9525 branch from 34c76a8 to e128742 Compare November 4, 2026 22:12
@mejo-
mejo- enabled auto-merge November 4, 2026 22:29
@mejo-
mejo- disabled auto-merge November 5, 2026 08:32
@mejo-
mejo- merged commit b5cc156 into stable34 Nov 5, 2026
66 of 68 checks passed
@mejo-
mejo- deleted the backport/stable34/9525 branch November 5, 2026 08:32
@github-project-automation github-project-automation Bot moved this from 👀 In review to ☑️ Done in 📝 Productivity team Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: ☑️ Done

Development

Successfully merging this pull request may close these issues.

1 participant