Skip to content

perf(runtimed-wasm): replace double-save() with get_heads() for sync change detection#591

Merged
rgbkrk merged 1 commit intomainfrom
quill/wasm-code-sync
Mar 7, 2026
Merged

perf(runtimed-wasm): replace double-save() with get_heads() for sync change detection#591
rgbkrk merged 1 commit intomainfrom
quill/wasm-code-sync

Conversation

@rgbkrk
Copy link
Member

@rgbkrk rgbkrk commented Mar 7, 2026

Replace expensive double-serialization with efficient head comparison in WASM sync message handling.

The receive_sync_message() method was calling doc.save() twice per incoming sync message to detect changes by comparing byte lengths. For large notebooks, this serializes the entire document (potentially megabytes) twice on every daemon sync.

Now uses doc.get_heads() which is O(number of heads) instead of O(document size).

Verification

  • Open a notebook and edit cells; verify edits sync smoothly between frontend and daemon with no console errors
  • Check larger notebooks (>100 cells) for responsive sync behavior

PR submitted by @rgbkrk's agent, Quill

…change detection

The WASM receive_sync_message method was calling doc.save() twice per
incoming sync message — once before and once after — just to compare
byte lengths as a proxy for "did anything change." For large notebooks
this serializes the entire document (potentially megabytes) twice on
every sync message from the daemon.

Replace with doc.get_heads() comparison, which returns the document's
current change hashes in O(number of heads) time instead of
O(document size).
@rgbkrk rgbkrk merged commit cbd41ca into main Mar 7, 2026
10 checks passed
@rgbkrk rgbkrk deleted the quill/wasm-code-sync branch March 7, 2026 23: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.

1 participant