Skip to content

Commit

Permalink
WIP: SEEC-channel-new
Browse files Browse the repository at this point in the history
  • Loading branch information
robinhundt committed May 26, 2024
1 parent d337ba3 commit 12f1436
Show file tree
Hide file tree
Showing 9 changed files with 2,957 additions and 57 deletions.
598 changes: 541 additions & 57 deletions Cargo.lock

Large diffs are not rendered by default.

1,932 changes: 1,932 additions & 0 deletions crates/seec-channel-new/Cargo.lock

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions crates/seec-channel-new/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "quic-serde-stream"
version = "0.1.0"
edition = "2021"

[features]
__bench = ["anyhow"]

[dependencies]
anyhow = { version = "1.0.86", optional = true }
s2n-quic = "1.37.0"
tokio = { version = "1.37.0", features = ["full"] }
pin-project-lite = "0.2.14"
serde = "1.0.203"
tokio-serde = { version = "0.9.0", features = ["bincode"] }
tokio-util = { version = "0.7.11", features = ["codec"] }

[dev-dependencies]
anyhow = { version = "1.0.86" }
criterion = { version = "0.4", features = ["html_reports", "async_tokio"] }
futures = "0.3.30"

[[bench]]
name = "bench"
harness = false
required-features = ["__bench"]
15 changes: 15 additions & 0 deletions crates/seec-channel-new/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SEEC-Channel

An improved asynchronous Channel for SEEC based on QUIC and 0-RTT sub-streams.

## TODO

- (optionally?) track number of bytes read and written for each sub-stream
- provide API to track communication as belonging to a (potentially nested) phase
- open question: this would track communication at the level of a QUIC stream and thus not include QUIC overhead. I
think there might be a way to get the complete communication amount via events, to at least report this overhead
- Multi-Channel
- Optional insecure communication? Currently, TLS is always used, but maybe a user wishes to not use it
- I think there is some testing code in s2n-quick for
this [here](https://github.com/aws/s2n-quic/blob/d03cc470fa9812d06d204e312e4ada00079e96df/quic/s2n-quic-core/src/crypto/tls/null.rs#L440)
only available with testing feature
68 changes: 68 additions & 0 deletions crates/seec-channel-new/benches/bench.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use quic_serde_stream::testing::local_conn;
use quic_serde_stream::Id;
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::Instant;
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::join;

fn criterion_benchmark(c: &mut Criterion) {
let rt = tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.unwrap();
let (mut server, _client) = rt.block_on(local_conn()).unwrap();
let id = AtomicU64::new(0);
let id = &id;
c.bench_function("create byte sub stream", |b| {
b.to_async(&rt).iter_batched(
|| server.clone(),
|mut server| async move {
let id = id.fetch_add(1, Ordering::Relaxed);
server.byte_sub_stream(Id::new(id)).await;
},
BatchSize::SmallInput,
)
});

id.store(0, Ordering::Relaxed);
let (server, client) = rt.block_on(local_conn()).unwrap();

c.bench_function("byte ping pong", |b| {
let mut server = &server;
let mut client = &client;
b.to_async(&rt).iter_custom(|iters| async move {
let mut server = server.clone();
let mut client = client.clone();
let id = id.fetch_add(1, Ordering::Relaxed);
let (mut snd_s, mut rcv_s) = server.byte_sub_stream(Id::new(id)).await;
let (mut snd_c, mut rcv_c) = client.byte_sub_stream(Id::new(id)).await;
let now = Instant::now();

for _ in 0..iters {
join!(
async {
snd_s.write_all(b"hello").await.unwrap();
},
async {
snd_c.write_all(b"hello").await.unwrap();
}
);
join!(
async {
let mut buf = [0; 5];
rcv_s.read_exact(&mut buf).await.unwrap();
},
async {
let mut buf = [0; 5];
rcv_c.read_exact(&mut buf).await.unwrap();
}
);
}
now.elapsed()
})
});
}

criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);
15 changes: 15 additions & 0 deletions crates/seec-channel-new/certs/cert.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----BEGIN CERTIFICATE-----
MIICRTCCAeugAwIBAgIUC989yXgvAxWhnaTdCsk8JgYpvzkwCgYIKoZIzj0EAwIw
gYExCzAJBgNVBAYTAkpQMQ4wDAYDVQQIDAVDaGliYTETMBEGA1UEBwwKQ2hpYmEg
Q2l0eTEYMBYGA1UECgwPVGVzc2llci1Bc2hwb29sMRAwDgYDVQQDDAdsb2NhbGNh
MSEwHwYJKoZIhvcNAQkBFhJjYUBkZXZlbG9wLmxvY2FsY2EwIBcNMjQwMzIzMDAz
NDMxWhgPMjIwMzA4MjkwMDM0MzFaMIGBMQswCQYDVQQGEwJKUDEOMAwGA1UECAwF
Q2hpYmExEzARBgNVBAcMCkNoaWJhIENpdHkxGDAWBgNVBAoMD1Rlc3NpZXItQXNo
cG9vbDEQMA4GA1UEAwwHbG9jYWxjYTEhMB8GCSqGSIb3DQEJARYSY2FAZGV2ZWxv
cC5sb2NhbGNhMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEbrmwtR2bEj/hit5i
7Vkh1wl3UqAykQFN801EYZC93qUp7XW9OB0U9kMk5K67Qb7239oL678jwtgJdBeo
DHa6C6M9MDswOQYDVR0RBDIwMIIJbG9jYWxob3N0ggtxbGF3cy5xbGF3c4cEfwAA
AYcQAAAAAAAAAAAAAAAAAAAAATAKBggqhkjOPQQDAgNIADBFAiAFj6aDZVkJm5v+
/f1MW9JCaWSdgzREF8wXRy4cWqZp3gIhAKprkqZOpfU4m1PLMuOqoRvnqz/r77uN
6nK1RbKK1pbF
-----END CERTIFICATE-----
5 changes: 5 additions & 0 deletions crates/seec-channel-new/certs/key.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-----BEGIN PRIVATE KEY-----
MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQgRlCQqSxQrvgT3BU7
xHp9ymk5r0RY2jccZOom+64gEv6hRANCAARuubC1HZsSP+GK3mLtWSHXCXdSoDKR
AU3zTURhkL3epSntdb04HRT2QyTkrrtBvvbf2gvrvyPC2Al0F6gMdroL
-----END PRIVATE KEY-----
Loading

0 comments on commit 12f1436

Please sign in to comment.