perf(runtimed-wasm): replace double-save() with get_heads() for sync change detection#591
Merged
perf(runtimed-wasm): replace double-save() with get_heads() for sync change detection#591
Conversation
…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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace expensive double-serialization with efficient head comparison in WASM sync message handling.
The
receive_sync_message()method was callingdoc.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
PR submitted by @rgbkrk's agent, Quill