ypy icon indicating copy to clipboard operation
ypy copied to clipboard

Async API

Open davidbrochart opened this issue 10 months ago • 7 comments

Since CRDTs can be CPU-intensive, I'm wondering if we could run all the Rust code in a separate thread, and have an async Python API that would not block while waiting for the CRDT operations to complete. For instance:

async with doc.begin_transaction() as txn:
    await ytext.extend(txn, "foo")
    ...

delta = await encode_state_as_update(doc)
await apply_update(other_doc, delta)

I know that Ypy doesn't support multi-threading, but here all the Rust code would run in the same thread (but this would not be the main Python thread). I think this would be a nice performance gain on multi-core CPUs. On single-core CPUs the non-async API would be a better choice.

davidbrochart avatar Sep 22 '23 09:09 davidbrochart