Live data from Hacker News

Monoio – A thread-per-core Rust async runtime with io_uring

github.com

31–40 of 84 posts

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#31

Earlier quoted context omitted.

"Async runtimes" is a thing that only makes sense for interpreted languages and their limitations. This thing is pure cargo cult and shows that Rust mostly appeals to newbies who don't know what they are doing.

Async models are idiomatic for high-performance server code regardless of the programming language, particularly for anything I/O or concurrency intensive. The reason people use thread-per-core software architectures, which naturally require an async model, is because they have much higher throughput than the alternatives. If software performance, efficiency, and scalability are primary objectives, you are going to b…

> ...is because they have much higher throughput than the alternatives

You're equating "high-performance" with "throughput". This is a classic newbie mistake and exactly what I mean when I mention cargo-cult.

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#32

Earlier quoted context omitted.

"Async runtimes" is a thing that only makes sense for interpreted languages and their limitations. This thing is pure cargo cult and shows that Rust mostly appeals to newbies who don't know what they are doing.

“Async” / event loop systems will usually be more efficient because 1) they don’t have to store unnecessary processor state to memory between handling events and 2) they are associated with cooperative event handlers and the assumption of a cooperative system provides more opportunities for optimization.

> ...and the assumption of a cooperative system provides more opportunities for optimization

Also much more opportunities for blocking and starvation. Especially when people try to reinvent schedulers without understanding how they work in the first place.

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#33
post #27

Earlier quoted context omitted.

“Async” / event loop systems will usually be more efficient because 1) they don’t have to store unnecessary processor state to memory between handling events and 2) they are associated with cooperative event handlers and the assumption of a cooperative system provides more opportunities for optimization.

Ironically, it is not true that "async" (stackless) event loop systems don't store unnecessary processor state to memory. Those systems store the entire processing state in future object memory. It is the same state that threaded systems store. Stackful context switching systems (which includes some kinds of efficient threads - I would count Linux kernel internal threads among these) store that same state in the stac…

> It is the same state that threaded systems store.

Nope. Synchronous task switching systems additionally have to store CPU register state. In the cooperative case you need to store the caller-saved registers, in the pre-emptive case you need to store all the registers.

Async systems simply don’t have to do that extra work.

> But some async, stackless systems do a bunch of extra work unwinding and restoring entire call stacks whenever an async task pauses in await

Just the really bad ones. In any competent system a callback is stored ready to handle the event. No “unwinding” necessary.

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#34
There are four articles in Chinese about the design and implementation on one of the author's blog. Here's a link to the first one: https://www.ihcblog.com/rust-runtime-design-1/. I don't know the subject and Chinese enough to know how much is lost by automatic translation (Google in my case), but it looks relatively good.

As an aside, Google translation integrated in Chrome breaks the formatting of the code blocks, which is surprising since they're in a

 block.

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#35
post #25

I wonder how much and for what Rust is being used at Bytedance, given that this seems to be under their GitHub org. It's pretty interesting that they are apparently using it. Edit: For those wondering who Bytedance are, I can save you a Google search. These are the people making TikTok.

Bytedance uses Rust extensively in Feishu/Lark (which competes with Microsoft Teams). It is even listed at https://www.rust-lang.org/production/users

From what I read (in Chinese), this "Monoio" is meant to be used for the proxy/whatever part of their next-generation service mesh. So maybe a corp-wide thing.

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#36

Earlier quoted context omitted.

io_uring is coming to Windows: https://twitter.com/axboe/status/1396837335141134336

Following that through to the blog post ([1]), it's interesting how much new API they had to add. The Windows IO API is already completion-style (as opposed to epoll, etc's readiness-style) - userspace submits an async operation to the kernel, blocks on a channel to receive its result, and the kernel enqueues the result to said channel when it's done. So I naively assumed that they'd "just" have to refit io_uring's A…

uring is used for disk-IO as well, and Windows disk I/O completion has similar limitations as Linux aio does for disks, i.e. anything that actually goes into filesystem code, like allocating new blocks, creating files, anything involving metadata, still blocks. Readiness-oriented I/O of course doesn't work for disk I/O at all, because disks are always ready. And IOCPs still mean that for queuing new I/O you're going to call into the kernel at least once for each operation.

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#37
I've found in my own use of rust I want async/nonblocking for two things.

1. Be able to timeout a read of a socket

2. Be able to select over multiple sockets, and read whichever is ready first

Usually a combination of both.

epoll/io_uring(I guess? I only ever did research on epoll) seem like the solution being handed to me on a silver platter, however my understanding is if you want to use either of those you're meant to use async in rust, and that while there are some libraries which provide interfaces for this kind of behavior outside of async, they're usually very ad-hoc and that the community is just very laser focused on async as a language construct. What I don't understand is why does Rust consider it necessary to introduce async, futures, runtimes, an executor, async versions of TcpListeners, Files, etc for this?

Why can't I just have a function in the standard library that takes a slice of std::net::TcpListeners, a timeout, blocks, and then gives me whichever is ready to read, when its ready to read, or nothing if the timeout is reached? Its not like I was going to do anything else on that thread while I wait for a packet to be received, it can happily be parked.

Instead I have to select a runtime, and libraries compatible with the runtime, replace all the TcpListeners from the standard library I'm using with tokio TcpListeners or whatever, deal with API change, and now I have to deal with the "turtles all the way down" problem of async as well.

That's not even to get into the whole nightmare that a lot of really sick libraries which I want to use in a blocking nature, are now only providing async APIs, which means its "async or the highway". I am very much not happy about this situation and I don't know what I can do about it. It seems the only response I ever get is "just use it, its easy" but that is not at all convincing me. I don't want to use it!

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#38
post #25

I wonder how much and for what Rust is being used at Bytedance, given that this seems to be under their GitHub org. It's pretty interesting that they are apparently using it. Edit: For those wondering who Bytedance are, I can save you a Google search. These are the people making TikTok.

It looks like they shared a lot of internal projects: https://github.com/orgs/bytedance/repositories

I'm pleasantly surprised. Have many other Chinese tech companies embraced FOSS?

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#39
post #37

I've found in my own use of rust I want async/nonblocking for two things. 1. Be able to timeout a read of a socket 2. Be able to select over multiple sockets, and read whichever is ready first Usually a combination of both. epoll/io_uring(I guess? I only ever did research on epoll) seem like the solution being handed to me on a silver platter, however my understanding is if you want to use either of those you're mean…

If you need to handle Async lets one process handle millions of sockets.

If you want to handle millions of sockets with threads, you can use `mio` [0]. Mio's API has footguns that can cause UB. If your wire protocol is complicated, you may find yourself implementing something like async, but worse.

[0] https://crates.io/crates/mio

Re: Monoio – A thread-per-core Rust async runtime with io_uring

#40
post #25

I wonder how much and for what Rust is being used at Bytedance, given that this seems to be under their GitHub org. It's pretty interesting that they are apparently using it. Edit: For those wondering who Bytedance are, I can save you a Google search. These are the people making TikTok.

It looks like they shared a lot of internal projects: https://github.com/orgs/bytedance/repositories I'm pleasantly surprised. Have many other Chinese tech companies embraced FOSS?

Yes its an increasing trend. Much of it is way less well known outside China. But lots of code from Alibaba, Tencent and smaller companies etc. many new CNCF projects are from China.
Post reply on HN