thubo 0.1.0

Thubo: a high-performance TX/RX network pipeline featuring strict priority scheduling, automatic batching, and message fragmentation.
Documentation

Thubo

Thubo is a high-performance TX/RX network pipeline featuring strict priority scheduling, automatic batching, and message fragmentation. It’s designed for applications that require predictable, priority-based message delivery, even under heavy load.

This is especially useful for protocols prone to head-of-line blocking (e.g., TCP/TLS), where a single large, low-priority message might otherwise delay urgent messages.

Why Thubo?

  • ⚑ Strict Priority Scheduling: high-priority messages preempt lower-priority flows.
  • πŸ“¦ Automatic Batching: maximizes throughput without manual tuning.
  • πŸ”€ Message Fragmentation: prevents head-of-line blocking by splitting large messages.
  • βš™οΈ Configurable Congestion Control: do not block on data that may get stale.

Overview

The diagram below illustrates the TX/RX network pipeline in operation, using all 4 priority queues (High, Medium, Low, Background).

                                                              .....
 APPLICATION SEND                                     User code   :
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”               :
β”‚    B1       β”‚  β”‚ L1 β”‚  β”‚ M1     β”‚  β”‚ H1 β”‚  β”‚ H2 β”‚               :
β””β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”¬β”€β”€β”˜  β””β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”¬β”€β”€β”˜  β””β”€β”¬β”€β”€β”˜               :
  t0              t1       t2         t3      t4                  :
   β–Ό               β–Ό        β–Ό          β–Ό       β–Ό                  :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  :
 TX PIPELINE                                 Thubo code           :
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  :
β”‚  Queues:                                                     β”‚  :
β”‚   P0 (High):       [H1][H2]           ← t3 ← t4              β”‚  :
β”‚   P1 (Medium):     [M1a, M1b]         ← t2                   β”‚  :
β”‚   P2 (Low):        [L1a, L1b]         ← t1                   β”‚  :
β”‚   P3 (Background): [B1a, B1b, B1c]    ← t0                   β”‚  :
|                                                              |  :
β”‚              t0     t1   t2   t3 t4                          β”‚  :
β”‚  Pull Order: B1a β†’ B1b β†’ L1a β†’ M1a β†’ H1 H2 β†’ M1b β†’ L1b β†’ B1c β”‚  :
β”‚                                                              β”‚  :
β”‚  TX Stream: [B1a][B1b][L1a][M1a][H1 H2][M1b][L1b][B1c]       β”‚  :
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  :
            |                                                 .....
            β–Ό Network
                                                              .....
 RX PIPELINE                                         Thubo code   :
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  :
β”‚  RX Stream: [B1a][B1b][L1a][M1a][H1 H2][M1b][L1b][B1c]       β”‚  :
β”‚                                                              β”‚  :
β”‚  Reassembled Messages: B1, L1, M1, H1, H2                    β”‚  :
β”‚                                                              β”‚  :
β”‚  Delivered by Priority: H1 β†’ H2 β†’ M1 β†’ L1 β†’ B1               β”‚  :
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  :
            β–Ό                                                     :
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  :
 APPLICATION RECEIVE                                  User code   :
β”Œβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                   :
β”‚ H1 β”‚ β”‚ H2 β”‚ β”‚ M1     β”‚ β”‚ L1 β”‚ β”‚    B1       β”‚                   :
β””β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                   :
                                                              .....

See documentation for a more detailed explaination.

Quick Start

use thubo::*;
use tokio::net::TcpStream;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Create a TCP connection
    let stream = TcpStream::connect("127.0.0.1:8080").await?;
    let (reader, writer) = stream.into_split();

    // Create bidirectional Thubo channel
    let (mut sender, sender_task) = thubo::sender(writer).build();
    let (mut receiver, receiver_task) = thubo::receiver(reader).build();

    // Send a message with default QoS
    sender.send(Bytes::from("my payload")).await?;

    // Receive messages in priority order
    let (msg, qos): (Bytes, QoS) = receiver.recv().await?;
    println!("Received message with QoS: {:?}", qos);

    Ok(())
}

Performance

Thubo can batch tens of millions of small messages per second and saturate multi-gigabit networks. The figure below shows the median throughput, with error bars representing the confidence interval, measured in messages per second (msg/s) and bits per second (bit/s). The y-axis is logarithmic.

plot

Thubo also achieves sub-millisecond latency, with ping times of a few tens of microseconds. The figure below shows the median latency, with error bars indicating the confidence interval. The y-axis is logarithmic.

plot