Skip to content

Conversation

@zxch3n
Copy link
Member

@zxch3n zxch3n commented Jan 6, 2026

This PR fixes two split-heavy performance bottlenecks that could degrade richtext import/checkout to near O(n^2) work.

What changed

  • Speed up InsertText slicing during ChangeStore split by avoiding repeated unicode→byte rescans.
  • Batch id_to_cursor remaps on CrdtRope leaf splits:
    • Tracker::update_insert_by_split now applies splits via IdToCursor::update_insert_batch.
    • InsertSet::update_many applies multiple ranges in one pass for small fragments (<= MAX_FRAGMENT_LEN) and falls back to per-range
      updates for larger ones.
  • Ignore local .trace_analysis/ artifacts.

Why

  • The split path previously re-walked large strings for each slice boundary.
  • Leaf-split remapping previously updated the same fragments repeatedly, amplifying scans/allocations in InsertSet::update.

zxch3n added 3 commits January 6, 2026 17:32
- Add ASCII/suffix fast paths in InnerListOp::slice to avoid O(n^2)
  unicode->byte scans
- Add ignored perf test reproducing split-suffix slicing pattern
- Batch leaf-split remaps via IdToCursor::update_insert_batch to reduce
  per-split InsertSet::update churn.
- Add InsertSet::update_many fast-path for small fragments (<=
  MAX_FRAGMENT_LEN) by rebuilding runs from a dense map.
- Ignore .trace_analysis/ artifacts.
@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

WASM Size Report

  • Original size: 3186.38 KB
  • Gzipped size: 1006.77 KB
  • Brotli size: 699.51 KB

zxch3n added 4 commits January 9, 2026 16:12
…text state

- Introduced a new method `content_node_len` to retrieve the length of content nodes.
- Enhanced the logic for determining when to apply fast updates for plain-text deltas, reducing unnecessary rebuilds.
- Improved performance by minimizing BTree mutations during incremental updates.
@zxch3n zxch3n merged commit 864b5ca into main Jan 9, 2026
1 check passed
@zxch3n zxch3n deleted the perf-import-text branch January 9, 2026 10:13
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.

2 participants