Skip to content

Commit

Permalink
chore: additional msrv updates
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft committed Feb 7, 2024
1 parent 8acab37 commit 86e0b7d
Show file tree
Hide file tree
Showing 19 changed files with 253 additions and 18 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ async fn main() -> Result<(), Box<dyn Error>> {

`s2n-quic` will maintain a rolling MSRV (minimum supported rust version) policy of at least 6 months. The current s2n-quic version is not guaranteed to build on Rust versions earlier than the MSRV.

The current MSRV is [1.63.0][msrv-url].
The current MSRV is [1.71.0][msrv-url].

## Security issue notifications

Expand All @@ -134,5 +134,5 @@ This project is licensed under the [Apache-2.0 License][license-url].
[docs-url]: https://docs.rs/s2n-quic
[dependencies-badge]: https://img.shields.io/librariesio/release/cargo/s2n-quic.svg
[dependencies-url]: https://crates.io/crates/s2n-quic/dependencies
[msrv-badge]: https://img.shields.io/badge/MSRV-1.63.0-green
[msrv-url]: https://blog.rust-lang.org/2022/08/11/Rust-1.63.0.html
[msrv-badge]: https://img.shields.io/badge/MSRV-1.71.0-green
[msrv-url]: https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html
2 changes: 1 addition & 1 deletion common/s2n-codec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-events/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "s2n-quic-events"
version = "0.1.0"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# This is a commit-time crate and should not be published
publish = false
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-h3/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "s2n-quic-h3"
version = "0.1.0"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# this contains an http3 implementation for testing purposes and should not be published
publish = false
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-platform/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-qns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name = "s2n-quic-qns"
version = "0.1.0"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
publish = false

Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-rustls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-sim/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "A simulation environment for s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
publish = false

Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-tls-default/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-tls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic-transport/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
2 changes: 1 addition & 1 deletion quic/s2n-quic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "A Rust implementation of the IETF QUIC protocol"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down
14 changes: 14 additions & 0 deletions tools/optimistic-quic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "optimistic-quic"
version = "0.1.0"
edition = "2021"

[dependencies]
bytes = "1"
mimalloc = { version = "0.1", default-features = false }
s2n-quic = { path = "../../quic/s2n-quic", features = ["provider-event-tracing"] }
tokio = { version = "1", features = ["full"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[workspace]
members = ["."]
3 changes: 3 additions & 0 deletions tools/optimistic-quic/rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[toolchain]
channel = "1.71.0"
components = [ "rustc", "clippy", "rustfmt" ]
218 changes: 218 additions & 0 deletions tools/optimistic-quic/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
use bytes::Bytes;
use core::time::Duration;
use s2n_quic::{
client::Connect,
connection,
provider::{event::tracing, limits::Limits, tls},
Client,
};
use std::{
net::SocketAddr,
sync::{
atomic::{AtomicU64, Ordering},
Arc,
},
};
use tokio::time::sleep;

#[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;

type Error = Box<dyn 'static + std::error::Error + Send + Sync>;
type Result<T = (), E = Error> = core::result::Result<T, E>;

macro_rules! log {
($($tt:tt)*) => {
// println!($($tt)*);
};
}

fn main() {
let format = tracing_subscriber::fmt::format()
.with_level(false) // don't include levels in formatted output
.with_timer(tracing_subscriber::fmt::time::uptime())
.with_ansi(false)
.compact(); // Use a less verbose output format.

tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.event_format(format)
.init();

let counter = Arc::new(AtomicU64::new(0));
std::thread::spawn({
let counter = counter.clone();
move || loop {
std::thread::sleep(Duration::from_secs(1));
let count = counter.swap(0, Ordering::Relaxed);
println!("{count} RPS");
}
});

let mut threads = vec![];

for _ in 0..1 {
let counter = counter.clone();
threads.push(std::thread::spawn(move || runner(counter)));
}

for thread in threads {
let _ = thread.join();
}
}

#[tokio::main(flavor = "current_thread")]
async fn runner(counter: Arc<AtomicU64>) -> Result {
let mut tls = tls::default::Client::builder().with_application_protocols(&[
"h3",
"hq-interop",
"perf",
])?;

unsafe {
tls.config_mut().disable_x509_verification()?;
}

let tls = tls.build()?;

let limits = Limits::default()
.with_max_open_local_unidirectional_streams(u32::MAX as _)?
.with_max_open_remote_unidirectional_streams(u32::MAX as _)?
.with_max_open_local_bidirectional_streams(u32::MAX as _)?
.with_max_open_remote_bidirectional_streams(u32::MAX as _)?;

let client = Client::builder()
.with_io("0.0.0.0:0")?
.with_tls(tls)?
.with_event(tracing::Provider::default())?
.with_limits(limits)?
.start()?;

/*
let host = std::env::args().nth(1).expect("missing server address");
let addr = tokio::net::lookup_host(&host).await?.next().unwrap();
dbg!(&host, &addr);
*/

let host = "localhost";
let addr: std::net::SocketAddr = "192.167.1.20:4433".parse()?;

//let host = "d4fzfzsp0rgmq.gamma.aws100.com";
//let addr: std::net::SocketAddr = "130.176.161.19:443".parse()?;

for _ in 0..10000 {
tokio::spawn(actor(
client.clone(),
host.to_string(),
addr,
counter.clone(),
));
}

actor(client, host.to_string(), addr, counter).await
}

async fn actor(client: Client, host: String, addr: SocketAddr, counter: Arc<AtomicU64>) -> Result {
loop {
let Ok(mut conn) = connect(&client, &host, addr).await else {
continue;
};

let mut burst = 1;

log!("probing burst");

loop {
let candidate = burst + 1;
log!("trying burst: {candidate}");

if let Err(err) = attack(&mut conn, candidate, &counter).await {
log!("{err}");
break;
}

burst = candidate;
}

if burst == 0 {
continue;
}

log!("selected burst: {burst}");

'retry_probe: loop {
if let Ok(mut conn) = connect(&client, &host, addr).await {
for _ in 0..10 {
if let Err(err) = attack(&mut conn, burst, &counter).await {
log!("burst failed; probing again");
log!("{err}");
break 'retry_probe;
}
}
}
}
}
}

async fn connect(
client: &Client,
host: &str,
addr: std::net::SocketAddr,
) -> Result<connection::Handle> {
let connect = Connect::new(addr).with_server_name(host);
log!("connecting: {connect}");
let conn = client.connect(connect).await?;

let (conn, mut accept) = conn.split();

/*
tokio::spawn(async move {
while let Ok(Some(stream)) = accept.accept().await {
tokio::spawn(retain(stream));
}
});
tokio::spawn({
let mut conn = conn.clone();
async move {
if let Ok(stream) = conn.open_bidirectional_stream().await {
retain(stream).await;
}
}
});
for ty in [Bytes::from_static(&[0x00])] {
tokio::spawn({
let mut conn = conn.clone();
async move {
if let Ok(mut stream) = conn.open_send_stream().await {
let _ = stream.send(ty).await;
retain(stream).await;
}
}
});
}
*/

Ok(conn)
}

async fn attack(conn: &mut connection::Handle, burst: usize, counter: &AtomicU64) -> Result {
for _ in 0..1_000 {
for _ in 0..burst {
let mut stream = conn.open_send_stream().await?;
let _ = stream.send(Bytes::from_static(&[4])).await;
let _ = stream.finish();
}
counter.fetch_add(burst as _, Ordering::Relaxed);
sleep(Duration::from_millis(1)).await;
}

Ok(())
}

async fn retain<T: 'static + Send>(value: T) {
let _: () = core::future::pending().await;
drop(value);
}
2 changes: 1 addition & 1 deletion tools/xdp/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.70.0"
channel = "1.71.1"
components = [ "rustc", "clippy", "rustfmt" ]
2 changes: 1 addition & 1 deletion tools/xdp/s2n-quic-xdp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description = "Internal crate used by s2n-quic"
repository = "https://github.com/aws/s2n-quic"
authors = ["AWS s2n"]
edition = "2021"
rust-version = "1.63"
rust-version = "1.71"
license = "Apache-2.0"
# Exclude corpus files when publishing to crates.io
exclude = ["corpus.tar.gz"]
Expand Down

0 comments on commit 86e0b7d

Please sign in to comment.