3 unstable releases
0.2.1 | Aug 23, 2024 |
---|---|
0.2.0 | Jul 22, 2024 |
0.1.0 | Jul 18, 2024 |
#697 in Network programming
1,081 downloads per month
Used in 3 crates
(2 directly)
180KB
3.5K
SLoC
SANS-I/O runtime (Working in progress)
(This module is in very early stage of development. It is not ready for production use.)
This is a simple, lightweight, and fast runtime for the SansIo mechanism.
Goal
The goal of this project is to provide a simple, lightweight, and fast runtime for the SansIo mechanism. The runtime should be able to run on any platform with variables network library like: mio, io_uring, af_xdp.
How it works
Controller will spawn some threads and each thread will run a worker. The workers
Features
Impl | C/I | Works | Benchmark | Group | Description |
---|---|---|---|---|---|
[x] | [ ] | [x] | [ ] | Control | Cross tasks communication |
[x] | [ ] | [x] | [x] | Control | Controller to worker communication |
[x] | [ ] | [x] | [ ] | Control | Controller to task communication |
[x] | [ ] | [x] | [ ] | Control | Workers status monitoring |
[x] | [ ] | [x] | [ ] | I/O | Udp |
[x] | [ ] | [x] | [ ] | I/O | Tun/Tap |
[ ] | [ ] | [ ] | [ ] | I/O | Tcp |
[ ] | [ ] | [ ] | [ ] | I/O | Rpc |
[x] | [ ] | [x] | [ ] | Backend | mio |
[x] | [ ] | [x] | [ ] | Backend | raw poll |
[x] | [ ] | [x] | [ ] | Backend | polling |
[ ] | [ ] | [ ] | [ ] | Backend | io_uring |
[ ] | [ ] | [ ] | [ ] | Backend | af_xdp |
[x] | [ ] | [x] | [ ] | Example | Udp echo server |
[x] | [ ] | [x] | [ ] | Example | Udp echo client |
[x] | [ ] | [x] | [ ] | Example | Simple Whip/Whep server |
Benchmarking
- External communication can archive 1.5M messages (1500 bytes) per second, that is 1.5M * 1500 * 8 = 18Gbps, this is just enough for almost of application. The latency is 2.5ms, because of we doing in polling base, maybe it can improve by using interrupt base.
Design
Single task
Bellow is state diagram of a single task.
stateDiagram
[*] --> Created
Created --> Waiting : attach to worker
Waiting --> OnTick : timer fired
OnTick --> Waiting : no output
OnTick --> PopOutput : has output
PopOutput --> PopOutput : has output
PopOutput --> Waiting : no output
Waiting --> OnInput : I/O, Bus
OnInput --> Waiting : no output
OnInput --> PopOutput : has output
The idea is in SAN/IO style, each task will reduce memory by create output immediately after input. We need to pop the output before we can receive the next input.
Multi tasks
With idea of SAN/IO is we need to pop the output before we can receive the next input. This is a problem when we have multiple tasks. We need to have a way to control the order of the tasks.
stateDiagram
[*] --> Created
Created --> Waiting : attach groups to worker
Waiting --> OnTick : timer fired
OnTick --> OnTickSingleTask : next task
OnTick --> Waiting : no task
OnTickSingleTask --> OnTick : no output
OnTickSingleTask --> PopCurrentTickTaskOutput : has output
PopCurrentTickTaskOutput --> PopCurrentTickTaskOutput : has output
PopCurrentTickTaskOutput --> OnTick : no output
Waiting --> OnInput : I/O, Bus
OnInput --> OnInputSingleTask : has task
OnInputSingleTask --> Waiting : no output
OnInputSingleTask --> PopCurrentInputTaskOutput : has output
PopCurrentInputTaskOutput --> PopCurrentInputTaskOutput : has output
PopCurrentInputTaskOutput --> Waiting : no output
Dependencies
~1–29MB
~435K SLoC