Reading updates out of order

I have a storage for yjs that does not guarantee that every item is read in the order it happened. For example, I have updates that happened in the following order:

update1
update2
update3

but they are read by Yjs in this order:

update3
update1
update2

It looks like Yjs is able to deal with this. My question is: are there any performance issues or limitations in such situations that need to be taken into account?

As long as each update is from a different user, with very little performance impact.

But if update 1-n are created by the same user, it will force a list sort on the list of structs that can not be applied yet.

Each struct has a unique id. E.g. struct1 = { id={client: 3, clock: 0}, content: 'a' }, struct2 = { id={client: 3, clock: 1}, content: 'b' }.

Structs by the same user are sorted by clock. They must be applied in order. struct2 must only be applied if all preceding structs have been applied.

So you apply the structs out of order, you will have an array of pending structs that must be sorted every time you add a struct to it. You can find the code that adds structs to pending structs here: https://github.com/yjs/yjs/blob/f4c919d9ec70f6c7eadc35d6758f1b8b35459d8e/src/utils/encoding.js#L254

There are probably some ways to optimize it, but generally I would rather try that structs by the same client are applied in-order.

Btw, you can apply structs by different clients out-of-order with very little performance impact. Yjs computes a unique path to apply all structs to the model. If structs are missing (because the struct that you currently want to execute depends on another struct), it will pause the integration process until the missing struct is found. More on this here: https://github.com/yjs/yjs/blob/f4c919d9ec70f6c7eadc35d6758f1b8b35459d8e/src/utils/encoding.js#L159

Thank you for the info!