News for hackers. Stuff that matters.
Re:A four year plan for async Rust by withoutboats3 on Tuesday November 07, 2023 @12:07PM (#38179487)
As a user who has maintained network services that communicate with Postgres, I'm very glad that sfackler's postgres library doesn't perform blocking IO calls, as that would make it unfit for purpose for me.
Re:A four year plan for async Rust by couchand on Tuesday November 07, 2023 @12:28PM (#38179852)
Maybe you misunderstand me. I'm not saying there shouldn't be a non-blocking version. I'm saying async is not a silver bullet. Some programs/teams/environments have different constraints than you.

Would you also advocate for the kernel to deprecate blocking i/o?

Re:A four year plan for async Rust by withoutboats3 on Tuesday November 07, 2023 @01:11PM (#38180523)
Obviously, it'd be better for someone who wants to talk to postgres and doesn't need non-blocking IO if a version based on blocking IO existed. But what is your grand point? It's not some conspiracy that libraries for network services use async/await: they most often do it because their maintainers need to use async/await in the work that pays for them to provide this open source library free of charge to you.

And all you need to do to not deal with async is wrap it in one of the many different block_on implementations. Yes, that's less ideal than not having to pull in these dependencies; if avoiding those dependencies is mission critical for you, maybe yours could be the enterprise that pays for the blocking IO postgres library.

Re:A four year plan for async Rust by chlorion on Tuesday November 07, 2023 @01:42PM (#38180977)
"async" and threads are not the only options for concurrent IO.

I've never saw anyone discuss using poll(2) style concurrency here which is interesting but also kind of sad.

With the mio crate for example, it uses the operating systems "select/poll" interface. On Linix this is epoll(7), but other OSes have their own interface.

"poll" style concurrency is a lot less complicated for me. The general idea is to register IO handles such as sockets into a data structure and pass it into the kernel. The kernel will emit events whenever a handle is ready to do something. There is the option to go to sleep and block until one of the handles are ready but it's not required.

"async" is an abstraction on top of this. The async runtime is handling the event loop and other stuff for you which is very useful but also a little bit complicated.

I am not in any way against "async" style concurrency but I think a lot of libraries could avoid pulling in a runtime and still be concurrent.

Re:A four year plan for async Rust by insanitybit on Tuesday November 07, 2023 @01:56PM (#38181165)
"mio" was the game in town for years and it was definitely not ideal at all, it was promising but very low level and most people didn't use it if they could help it. People wanted async/await.
Re:A four year plan for async Rust by bryanlarsen on Tuesday November 07, 2023 @02:11PM (#38181355)
Several of my rust programs use tokio's select! macro as their main loop. I really like that pattern.