<@U085BL9DBU4> About async io. It is not possible ...
# io
a
@Alexander Hinze About async io. It is not possible to create a async io and keep the performance level the same. It is why kotlnx-io does not have async functions. Ktor-io adds them, but there are some nasty hacks.
👀 1
a
Kotlinx-io team has been trying it for a long time. And it is just not possible without sacrificing performance
📝 1
👍 1
o
There is a design for Async IO in kotlinx-io: https://github.com/Kotlin/kotlinx-io/issues/163. But AFAIK, there isn't much work going on that front, mostly because there aren't many use cases for it, and ktor (the biggest client for that feature) has its own async IO similar to the one in the proposal. cc @Filipp Zhinkin, as I might forget some details, from the last time I asked you about it. kodee floating
true 1
And it is just not possible without sacrificing performance
IMO, it's not true. Performance sacrifices will be imposed only if we expose
suspend
operations like `readInt`/`readLong`/etc. (e.g., primitive ones). The proposal above, where only `suspend`able
read/write
calls are exposed, should work fine performance-wise for use cases where Async IO is needed (e.g., sockets).
🙌 1
a
You can introduce suspend function to block writes. But you can do the same right now on top of kotlinx-io
If you make primitive writes suspended, then you will loose performance
o
Yes, that's exactly what I mentioned above. 🙂 Though, maybe I didn't understand the initial thread message. I mean, for use cases where Async IO operations are needed, bulk operations probably cover the main use cases.
a
@altavir Yes i know, i built this API not for performance reasons primarily, but the ability to work on web targets properly, and it's a dependency for my resource compiler tooling used in my game engine, since it also supports WASM. I will still specialize a lot of IO code per platform in my actual application to optimize certain cases. That's why i also have an MMIO lib for kotlinx.io which is synchronous 😄
And that's why having both, a blocking and async IO API is nice in my use case