News for hackers. Stuff that matters.
Re:Collaborative Text Editing Without CRDTs or OT by poly2it on Wednesday May 21, 2025 @02:30PM (#44054598)
Why not just use an ever incrementing u64?
Re:Collaborative Text Editing Without CRDTs or OT by kortex on Wednesday May 21, 2025 @02:58PM (#44054931)
Then you need central coordination, either a single central server containing the counter, or something like Snowflake where you have multiple counters, each assigned orthogonal blocks ahead of time (that need to coordinate with a central server).

UUIDs/ULIDs/etc are fully distributed, you can have two clients assign an ID without coordinating with ~0% of collision.

Re:Collaborative Text Editing Without CRDTs or OT by poly2it on Wednesday May 21, 2025 @03:10PM (#44055069)
You could also split the u64 to have the first 24 bits be unique to the client, and the last 40 be unique to the produced character. This would still allow 1 TiB of data produced per user and session. The single mutex would be the user ID counter.
Re:Collaborative Text Editing Without CRDTs or OT by zamadatix on Wednesday May 21, 2025 @02:49PM (#44054817)
An incrementing u64 requires either atomic increments between concurrent clients or recalculation logic to consistently find the newly incremented ID after conflicting information syncs. UUIDs just spit out a unique ID without any complexity or associations with other clients.
Re:Collaborative Text Editing Without CRDTs or OT by ChadNauseam on Wednesday May 21, 2025 @03:26PM (#44055238)
There's closely related idea that might work, though. Each device editing text could be assigned a 32-bit ID by the server (perhaps auto-incrementing). Devices then maintain a separate 32-bit ID that they increment for each operation they perform. The ID used for each character is (device_id, edit_id), which should fit nicely in 8 bytes.
Re:Collaborative Text Editing Without CRDTs or OT by mweidner on Wednesday May 21, 2025 @03:40PM (#44055419)
Indeed, this is close to what Yjs (popular CRDT library) does: each client instance (~ browser tab) chooses a random 32-bit clientId, and character IDs combine this clientId with local counters. https://github.com/yjs/yjs/blob/987c9ebb5ad0a2a89a0230f3a0c6...

Any given collaborative document will probably only see ~1k clientIds in its lifetime, so the odds of a collision are fairly low (though I'd be more comfortable with a 64-bit ID).