• Stars
    star
    157
  • Rank 238,399 (Top 5 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Minimal non-blocking I/O for Rust

popol

Minimal non-blocking I/O for Rust.

See examples/ folder for usage.

Overview

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.

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:

  • Much smaller implementation than even the smallest async/await runtimes
  • All of the Rust standard library just works (io::Read, io::Write, etc.)
  • Virtually zero-dependency (the libc crate is the only dependency)
  • No "runtime". Keeps the code much easier to reason about

Why not use epoll? A couple of reasons:

  1. It is more complex than poll and requires us to write more code
  2. It isn't portable (only works on Linux)
  3. poll is sufficient for handling most workloads

Compared to mio, popol is:

  • A lot smaller (about 10% of the size)
  • A little more flexible and easy to use
  • Supports standard library sockets
  • Currently focused on unix-based system compatibility

Some of the advantages of popol's API over mio's:

  • popol supports multiple wakers per wait call.
  • popol event source identifiers are not limited to u64.
  • popol's API is composed mostly of infallible functions.

On the other hand, mio is more mature and probably better at handling very large number of connections. Mio also currently supports more platforms.

License

This software is licensed under the MIT license. See the LICENSE file for details.

About

(c) Alexis Sellier https://cloudhead.io

More Repositories

1

rx

๐Ÿ‘พ Modern and minimalist pixel editor
Rust
2,920
star
2

node-static

rfc 2616 compliant HTTP static-file server module, with built-in caching.
JavaScript
2,171
star
3

toto

the 10 second blog-engine for hackers
Ruby
1,473
star
4

http-console

simple, intuitive HTTP REPL โ€” Speak HTTP like a local.
JavaScript
1,358
star
5

eyes.js

a customizable value inspector for node.js
JavaScript
342
star
6

journey

liberal JSON-only HTTP request routing for node.
JavaScript
321
star
7

nakamoto

Privacy-preserving Bitcoin light-client implementation in Rust
Rust
303
star
8

thingler

The amazingly simple-to-use, real-time, collaborative todo list!
JavaScript
296
star
9

dorothy

a basic template for toto, the blogging engine
Ruby
244
star
10

hijs

simple & fast javascript syntax highlighting for the browser
JavaScript
240
star
11

rgx.legacy

Modern mid-level 2D graphics library
Rust
194
star
12

neovim-fuzzy

Minimalistic fuzzy file finding for neovim
Vim Script
111
star
13

dotfiles

~cloudhead
Vim Script
100
star
14

mutter

the tiny command-line interface library with lots of style~
Ruby
80
star
15

resourcer

a resource-oriented object-relational mapper for document databases
JavaScript
58
star
16

pixelog

simple pixel tracking server
Go
56
star
17

node-syslog

a syslog-ng TCP client, with basic fault-tolerance.
JavaScript
32
star
18

koi

minimal task management for hackers
Ruby
31
star
19

nonempty

Correct by construction non-empty list
Rust
30
star
20

px

Superseded by `rx`
C
30
star
21

erlapp.template

minimal erlang/OTP rebar template
Erlang
29
star
22

styleguide

style-guide for various languages
27
star
23

shady.vim

Shady vim color-scheme for late night hacking
Vim Script
23
star
24

vargs

practical variable argument handling in node.js
JavaScript
22
star
25

neovim-ghcid

Provides instant haskell error feedback inside of neovim, via ghcid.
Vim Script
21
star
26

microserde

miniserde minus the dependencies
Rust
18
star
27

pilgrim

a JSON consuming JavaScript XHR client for the browser
JavaScript
15
star
28

nimbus

nimble, durable, document store
JavaScript
14
star
29

spell-correct

ruby implementation of Norvig's spell corrector
Ruby
12
star
30

node-crawler

http crawler โ€” (project under development)
JavaScript
12
star
31

arbre

a dynamic functional programming language experiment
C
10
star
32

rig.js

temporally extend an object's capabilities.
JavaScript
9
star
33

mrchat

micro chat client for the console, in c, with some tasteful ncurses
C
9
star
34

talker-plugins

A bunch of plugins for Talker (http://talkerapp.com)
JavaScript
9
star
35

node-provider

Manage HTTP content providers. It's 'Accept'-based routing, folks!
JavaScript
9
star
36

proto.js

prototype & other core extensions
JavaScript
8
star
37

github-unwatcher

Unwatch github repos
JavaScript
8
star
38

memoir

Self-describing, reflective parser combinators
Rust
7
star
39

spinsv

a stateless service runner inspired by runit
Haskell
7
star
40

avl-auth

An authenticated AVL+ tree implementation in Haskell
Haskell
6
star
41

bloomy

Bloom filter implementation in Rust
Rust
6
star
42

gogol

a bitmap drawing & animation library for Go
Go
6
star
43

cloudhead.io

This is my website.
CSS
5
star
44

prose

lightweight text to html parser, combining the best of Markdown with a hint of Textile
Ruby
5
star
45

s3web

scripts for publishing static sites to S3
Ruby
4
star
46

github-recommend

recommendation engine for github's 2009 contest
C
4
star
47

monsv

a service runner inspired by runsv
Go
3
star
48

diffraction

even stocks can be diffracted!
Ruby
3
star
49

melon

hybrid javascript/ruby micro app engine
Ruby
3
star
50

node-intro

intro to node.js presentation for montreal.js
JavaScript
3
star
51

cryptocurrency

Cryptocurrency library for Haskell
Haskell
2
star
52

golem

pre-forking HTTP server for node (old)
JavaScript
2
star
53

ghoul

your (node) deployment minion - a work in progress.
PHP
2
star
54

rx.cloudhead.io

CSS
2
star
55

birth

graceful linux system birthing
Vim Script
2
star
56

extender

handy extensions to keep your code cleanโ„ข
Ruby
2
star
57

sokol-gfx-rs

C
1
star
58

iohk-challenge

IOHK Haskell test
Haskell
1
star
59

a-file-uploader

JavaScript
1
star
60

rgx

2D Graphics Toolkit for Rust
Rust
1
star