Skip to content

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

Merged
mejo- merged 1 commit into
stable35from
backport/9525/stable35
Nov 4, 2026
Merged

mejo- merged 1 commit into
stable35from
backport/9525/stable35

Conversation

@backportbot

@backportbot backportbot Bot commented Nov 4, 2026

Copy link
Copy Markdown

Backport of PR #9525

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
@backportbot
backportbot Bot requested a review from benjaminfrueh November 4, 2026 08:19
@backportbot backportbot Bot added 3. to review performance 🚀 AI assisted This PR contains AI-assisted commits labels Nov 4, 2026
@backportbot backportbot Bot added this to the Nextcloud 35.0.3 milestone Nov 4, 2026
@mejo-
mejo- merged commit e5797c9 into stable35 Nov 4, 2026
62 of 64 checks passed
@mejo-
mejo- deleted the backport/9525/stable35 branch November 4, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review AI assisted This PR contains AI-assisted commits performance 🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant