-
-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow encoding awareness values as binary in updates #26
Comments
Hi @Myrannas, I'm not sure if this is worth the trouble right now. FYI: We are experimenting with several ideas to replace the current (extremely simple) Awareness CRDT. A v2 based on any-encoding would only slightly decrease the size of messages in most cases (Awareness is mainly used for syncing small updates like cursor positions and user names). I'd accept a PR that adds the suggested optional parameter for a custom Awareness encoder. At this time, I'd not accept a PR that switches the default awareness protocol for a (slightly improved) v2 encoder. I don't think it's worth the trouble to switch the protocol right now. We are currently trying to maintain compatibility with the y-crdt project. I'd like to wait for a much-improved Awareness implementation before we change the default protocol. |
Thanks for the heads up! Makes sense for a lot of teams it may not make a large difference. For my use case, we anticipate this would make a large difference as we are using it to share some information like the current selection state (which can be 1000s of items). I'll prepare a PR that would allow for a custom encoder, but leave the default as is. Is there anywhere to read about the improved awareness implementation? I'd love to see what the plan is for that. |
…xported encoding and decoding methods, and add a binary encoding strategy.
…xported encoding and decoding methods, and add a binary encoding strategy.
…xported encoding and decoding methods, and add a binary encoding strategy.
y-protocols/awareness
currently encodes updates using a combination ofwriteVarString
andJSON.stringify
today.The codebase I am working on uses a decent amount of single precision floating point numbers in awareness, and so would benefit from binary encoding. My understanding is that
lib0
can encode arbitrary structures as binary using thewriteAny
method (used inyjs
).Backwards compatibility may be a little difficult with introducing binary encoding, as old clients would expect a JSON stringified value. To allow users of the library to control the rollout, it might be possible to introduce similar functionality to how YJS supports V1 and V2 updates - where an encoder is passed in as a parameter (with a default value).
For example:
Would you be open to accepting a contribution with these changes?
The text was updated successfully, but these errors were encountered: