diff --git a/.github/workflows/qns.yml b/.github/workflows/qns.yml index dee3539395..847720a60c 100644 --- a/.github/workflows/qns.yml +++ b/.github/workflows/qns.yml @@ -72,10 +72,9 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: - mode: ["debug", "release"] - # enable debug information + profile: ["debug", "release"] env: - RUSTFLAGS: "-g --cfg s2n_internal_dev --cfg s2n_quic_dump_on_panic --cfg s2n_quic_unstable" + RUSTFLAGS: "--cfg s2n_internal_dev --cfg s2n_quic_dump_on_panic --cfg s2n_quic_unstable" steps: - uses: actions/checkout@v4 with: @@ -90,18 +89,20 @@ jobs: - uses: camshaft/rust-cache@v1 with: - key: ${{ matrix.mode }}-${{ env.RUSTFLAGS }} + key: ${{ matrix.profile }}-${{ env.RUSTFLAGS }} - name: Run cargo build - uses: actions-rs/cargo@v1.0.3 - with: - command: build - args: --bin s2n-quic-qns ${{ matrix.mode == 'release' && '--release' || '' }} + env: + QNS_PROFILE: ${{ matrix.mode == 'release' && '--profile=release-debug' || '' }} + run: | + cargo build --bin s2n-quic-qns $QNS_PROFILE - name: Prepare artifact + env: + QNS_PROFILE: ${{ matrix.mode == 'release' && 'release-debug' || 'debug' }} run: | mkdir -p s2n-quic-qns - cp target/${{ matrix.mode }}/s2n-quic-qns s2n-quic-qns/s2n-quic-qns-${{ matrix.mode }} + cp target/$QNS_PROFILE/s2n-quic-qns s2n-quic-qns/s2n-quic-qns-${{ matrix.profile }} - uses: actions/upload-artifact@v4 with: @@ -504,8 +505,9 @@ jobs: - name: Setup artifacts run: | - mv target/release/s2n-quic-qns-release target/release/s2n-quic-qns - chmod +x target/release/s2n-quic-qns + mkdir -p target/release-debug + mv target/release/s2n-quic-qns-release target/release-debug/s2n-quic-qns + chmod +x target/release-debug/s2n-quic-qns - name: Run script env: diff --git a/Cargo.toml b/Cargo.toml index aaabc3f130..0644bd0903 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,11 +10,6 @@ exclude = [ "tools", ] -[profile.release] -lto = true -codegen-units = 1 -incremental = false - [profile.bench] lto = true codegen-units = 1 @@ -27,3 +22,11 @@ inherits = "dev" opt-level = 3 incremental = false codegen-units = 1 + +[profile.release-debug] +inherits = "release" +debug-assertions = true +debug = true + +[profile.release-bench] +inherits = "bench" diff --git a/quic/s2n-quic-qns/Cargo.toml b/quic/s2n-quic-qns/Cargo.toml index 1c1abfa1b2..5a29529cf7 100644 --- a/quic/s2n-quic-qns/Cargo.toml +++ b/quic/s2n-quic-qns/Cargo.toml @@ -9,7 +9,9 @@ license = "Apache-2.0" publish = false [features] -default = [] +default = ["interop", "perf"] +interop = [] +perf = [] trace = ["s2n-quic-core/branch-tracing", "s2n-quic-core/probe-tracing", "s2n-quic-core/usdt"] xdp = ["s2n-quic/unstable-provider-io-xdp", "aya", "aya-log"] diff --git a/quic/s2n-quic-qns/src/client.rs b/quic/s2n-quic-qns/src/client.rs index 18f07dd082..9b6824fa75 100644 --- a/quic/s2n-quic-qns/src/client.rs +++ b/quic/s2n-quic-qns/src/client.rs @@ -1,12 +1,18 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "interop")] mod h09; +#[cfg(feature = "interop")] mod h3; +#[cfg(feature = "interop")] pub mod interop; +#[cfg(feature = "perf")] pub mod perf; +#[cfg(feature = "interop")] pub use interop::Interop; +#[cfg(feature = "perf")] pub use perf::Perf; use crate::{ diff --git a/quic/s2n-quic-qns/src/main.rs b/quic/s2n-quic-qns/src/main.rs index 230127ca7d..4bd56affb9 100644 --- a/quic/s2n-quic-qns/src/main.rs +++ b/quic/s2n-quic-qns/src/main.rs @@ -8,11 +8,14 @@ pub type Result = core::result::Result; mod client; mod congestion_control; +#[cfg(feature = "interop")] mod file; mod intercept; +#[cfg(feature = "interop")] mod interop; mod io; mod limits; +#[cfg(feature = "perf")] mod perf; mod runtime; mod server; @@ -65,25 +68,31 @@ fn main() { #[derive(Debug, StructOpt)] enum Arguments { + #[cfg(feature = "interop")] Interop(Interop), + #[cfg(feature = "perf")] Perf(Perf), } impl Arguments { pub fn run(&self) -> Result<()> { match self { + #[cfg(feature = "interop")] Self::Interop(subject) => subject.run(), + #[cfg(feature = "perf")] Self::Perf(subject) => subject.run(), } } } +#[cfg(feature = "interop")] #[derive(Debug, StructOpt)] enum Interop { Server(server::Interop), Client(client::Interop), } +#[cfg(feature = "interop")] impl Interop { pub fn run(&self) -> Result<()> { match self { @@ -93,12 +102,14 @@ impl Interop { } } +#[cfg(feature = "perf")] #[derive(Debug, StructOpt)] enum Perf { Server(server::Perf), Client(client::Perf), } +#[cfg(feature = "perf")] impl Perf { pub fn run(&self) -> Result<()> { match self { diff --git a/quic/s2n-quic-qns/src/server.rs b/quic/s2n-quic-qns/src/server.rs index 80c9e59d0b..496c866100 100644 --- a/quic/s2n-quic-qns/src/server.rs +++ b/quic/s2n-quic-qns/src/server.rs @@ -1,14 +1,20 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 +#[cfg(feature = "interop")] mod h09; +#[cfg(feature = "interop")] mod h3; +#[cfg(feature = "interop")] pub mod interop; +#[cfg(feature = "perf")] pub mod perf; #[cfg(all(s2n_quic_unstable, feature = "unstable_client_hello"))] mod unstable; +#[cfg(feature = "interop")] pub use interop::Interop; +#[cfg(feature = "perf")] pub use perf::Perf; use crate::{ diff --git a/quic/s2n-quic-qns/src/server/h09.rs b/quic/s2n-quic-qns/src/server/h09.rs index 43f64570c4..de223bc003 100644 --- a/quic/s2n-quic-qns/src/server/h09.rs +++ b/quic/s2n-quic-qns/src/server/h09.rs @@ -3,7 +3,6 @@ use crate::{ file::{abs_path, File}, - server::interop::MyConnectionContext, Result, }; use bytes::Bytes; @@ -20,10 +19,6 @@ pub(crate) async fn handle_connection(mut connection: Connection, www_dir: Arc

{ - let _ = connection.query_event_context_mut(|context: &mut MyConnectionContext| { - context.stream_requests += 1 - }); - let www_dir = www_dir.clone(); // spawn a task per stream tokio::spawn(async move { @@ -33,19 +28,10 @@ pub(crate) async fn handle_connection(mut connection: Connection, www_dir: Arc

{ - // the connection was closed without an error - let context = connection - .query_event_context(|context: &MyConnectionContext| *context) - .expect("query should execute"); - debug!("Final stats: {context:?}"); return; } Err(err) => { eprintln!("error while accepting stream: {err}"); - let context = connection - .query_event_context(|context: &MyConnectionContext| *context) - .expect("query should execute"); - debug!("Final stats: {context:?}"); return; } } diff --git a/quic/s2n-quic-qns/src/server/interop.rs b/quic/s2n-quic-qns/src/server/interop.rs index 24b8b4e42a..75e4a0c11b 100644 --- a/quic/s2n-quic-qns/src/server/interop.rs +++ b/quic/s2n-quic-qns/src/server/interop.rs @@ -104,10 +104,7 @@ impl Interop { .with_io(io)? .with_endpoint_limits(endpoint_limits)? .with_limits(limits)? - .with_event(( - EventSubscriber, - s2n_quic::provider::event::tracing::Subscriber::default(), - ))?; + .with_event(s2n_quic::provider::event::tracing::Subscriber::default())?; // setup the packet interceptor if internal dev #[cfg(s2n_internal_dev)] @@ -145,35 +142,3 @@ fn is_supported_testcase(testcase: Testcase) -> bool { ConnectionMigration => true, } } - -#[derive(Debug, Clone, Copy)] -pub struct MyConnectionContext { - packet_sent: u64, - pub(crate) stream_requests: u64, -} - -pub struct EventSubscriber; - -impl Subscriber for EventSubscriber { - type ConnectionContext = MyConnectionContext; - - fn create_connection_context( - &mut self, - _meta: &events::ConnectionMeta, - _info: &events::ConnectionInfo, - ) -> Self::ConnectionContext { - MyConnectionContext { - packet_sent: 0, - stream_requests: 0, - } - } - - fn on_packet_sent( - &mut self, - context: &mut Self::ConnectionContext, - _meta: &events::ConnectionMeta, - _event: &events::PacketSent, - ) { - context.packet_sent += 1; - } -} diff --git a/scripts/perf/bin/quinn b/scripts/perf/bin/quinn deleted file mode 100755 index 2e9fa57f35..0000000000 --- a/scripts/perf/bin/quinn +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -# -# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -set -e - -case "$PS" in - server*) - ../../target/perf/quinn/bin/perf_server \ - --port $SERVER_PORT - ;; - client*) - ../../target/perf/quinn/bin/perf_client \ - --download-size "$DOWNLOAD_BYTES" \ - --upload-size "$UPLOAD_BYTES" \ - --duration $DURATION \ - localhost:$SERVER_PORT - ;; -esac diff --git a/scripts/perf/bin/s2n-quic b/scripts/perf/bin/s2n-quic index 108333a5f2..806c01906f 100755 --- a/scripts/perf/bin/s2n-quic +++ b/scripts/perf/bin/s2n-quic @@ -9,7 +9,7 @@ set -e case "$PS" in server*) - ../../target/release/s2n-quic-qns \ + exec ../../target/release-debug/s2n-quic-qns \ perf \ server \ --port $SERVER_PORT \ @@ -17,7 +17,7 @@ case "$PS" in --stats ;; client*) - ../../target/release/s2n-quic-qns \ + exec ../../target/release-debug/s2n-quic-qns \ perf \ client \ --receive "${DOWNLOAD_BYTES}" \ diff --git a/scripts/perf/bin/s2n-quic-null b/scripts/perf/bin/s2n-quic-null index b40e624e35..42d1259b1a 100755 --- a/scripts/perf/bin/s2n-quic-null +++ b/scripts/perf/bin/s2n-quic-null @@ -9,7 +9,7 @@ set -e case "$PS" in server*) - ../../target/release/s2n-quic-qns \ + exec ../../target/release-debug/s2n-quic-qns \ perf \ server \ --port $SERVER_PORT \ @@ -18,7 +18,7 @@ case "$PS" in --stats ;; client*) - ../../target/release/s2n-quic-qns \ + exec ../../target/release-debug/s2n-quic-qns \ perf \ client \ --receive "${DOWNLOAD_BYTES}" \ diff --git a/scripts/perf/build b/scripts/perf/build index 5d1bc22ff8..91223afa74 100755 --- a/scripts/perf/build +++ b/scripts/perf/build @@ -15,20 +15,10 @@ if ! command -v "ultraman" &> /dev/null; then cargo install ultraman fi -if [ ! -f target/perf/quinn/bin/perf_client ] || [ ! -f target/perf/quinn/bin/perf_server ]; then - mkdir -p target/perf/quinn - cargo +stable install \ - --git https://github.com/quinn-rs/quinn \ - --rev 6e4bcbb2fcb57ced2ef261c9662521c5baf37f3c \ - --bin perf_client \ - --bin perf_server \ - --root target/perf/quinn \ - --target-dir target/perf/quinn \ - perf -fi - cargo \ +stable \ build \ --bin s2n-quic-qns \ - --profile bench + --profile release-debug \ + --no-default-features \ + --features perf