Minimal non-blocking I/O for Rust.
Async I/O in Rust is still an unsolved problem. With the stabilization of
async/await, we are seeing a number of libraries and runtimes crop up, such
as async-std and smol, while others such as tokio and mio are maturing.
The problem with async/await is that you can't use any of the standard
library traits, such as Read
and Write
. The async ecosystem comes with an
entirely separate suite of traits (eg. AsyncRead
and AsyncWrite
) and I/O
libraries. Furthermore, most of these runtimes have a large dependency
footprint, partly from having to provide async alternatives to the standard
library functions, and partly due to the complexity of these runtimes.
Finally, async/await has a very steep learning curve and has a lot of
rough edges.
What do we need? For most use-cases, the ability to handle between a dozen
and up to a few hundred open connections without blocking, is all we need.
This places us squarely within the territory of the venerable poll()
function,
which is available on almost all platforms.
Popol is designed as a minimal ergonomic wrapper around poll()
, built for
peer-to-peer networking.
By building on poll
, we have the following advantages:
io::Read
, io::Write
, etc.)Why not use epoll
? A couple of reasons:
poll
and requires us to write more codepoll
is sufficient for handling most workloadsCompared to mio, popol is:
On the other hand, mio is a lot more mature and better at handling very large number of connections