Skip to content

Commit

Permalink
clean up perf runs
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft committed Feb 7, 2024
1 parent 185aec5 commit ce2206a
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 107 deletions.
26 changes: 14 additions & 12 deletions .github/workflows/qns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -90,22 +89,24 @@ jobs:

- uses: camshaft/rust-cache@v1
with:
key: ${{ matrix.mode }}-${{ env.RUSTFLAGS }}
key: ${{ matrix.profile }}-${{ env.RUSTFLAGS }}

- name: Run cargo build
uses: actions-rs/[email protected]
with:
command: build
args: --bin s2n-quic-qns ${{ matrix.mode == 'release' && '--release' || '' }}
env:
QNS_PROFILE: ${{ matrix.profile == 'release' && '--profile=release-debug' || '' }}
run: |
cargo build --bin s2n-quic-qns $QNS_PROFILE
- name: Prepare artifact
env:
QNS_PROFILE: ${{ matrix.profile == '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:
name: s2n-quic-qns-${{ matrix.mode }}
name: s2n-quic-qns-${{ matrix.profile }}
path: s2n-quic-qns/

interop:
Expand Down Expand Up @@ -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:
Expand Down
13 changes: 8 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ exclude = [
"tools",
]

[profile.release]
lto = true
codegen-units = 1
incremental = false

[profile.bench]
lto = true
codegen-units = 1
Expand All @@ -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"
4 changes: 3 additions & 1 deletion quic/s2n-quic-qns/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]

Expand Down
6 changes: 6 additions & 0 deletions quic/s2n-quic-qns/src/client.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
11 changes: 11 additions & 0 deletions quic/s2n-quic-qns/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ pub type Result<T, E = Error> = core::result::Result<T, E>;

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;
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions quic/s2n-quic-qns/src/server.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
14 changes: 0 additions & 14 deletions quic/s2n-quic-qns/src/server/h09.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use crate::{
file::{abs_path, File},
server::interop::MyConnectionContext,
Result,
};
use bytes::Bytes;
Expand All @@ -20,10 +19,6 @@ pub(crate) async fn handle_connection(mut connection: Connection, www_dir: Arc<P
loop {
match connection.accept_bidirectional_stream().await {
Ok(Some(stream)) => {
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 {
Expand All @@ -33,19 +28,10 @@ pub(crate) async fn handle_connection(mut connection: Connection, www_dir: Arc<P
});
}
Ok(None) => {
// 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;
}
}
Expand Down
37 changes: 1 addition & 36 deletions quic/s2n-quic-qns/src/server/interop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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;
}
}
22 changes: 0 additions & 22 deletions scripts/perf/bin/quinn

This file was deleted.

4 changes: 2 additions & 2 deletions scripts/perf/bin/s2n-quic
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ set -e

case "$PS" in
server*)
../../target/release/s2n-quic-qns \
exec ../../target/release-debug/s2n-quic-qns \
perf \
server \
--port $SERVER_PORT \
--max-mtu 16000 \
--stats
;;
client*)
../../target/release/s2n-quic-qns \
exec ../../target/release-debug/s2n-quic-qns \
perf \
client \
--receive "${DOWNLOAD_BYTES}" \
Expand Down
4 changes: 2 additions & 2 deletions scripts/perf/bin/s2n-quic-null
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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}" \
Expand Down
16 changes: 3 additions & 13 deletions scripts/perf/build
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit ce2206a

Please sign in to comment.