Skip to content

8xFF/sans-io-runtime

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License: MIT Discord

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
  • 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

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