Skip to content

Commit

Permalink
avoid writing on stdout with --perf
Browse files Browse the repository at this point in the history
  • Loading branch information
frochet committed Jan 24, 2024
1 parent b69a265 commit 06c1bb1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions apps/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ Options:
--session-file PATH File used to cache a TLS session for resumption.
--source-port PORT Source port to use when connecting to the server [default: 0].
--initial-cwnd-packets PACKETS The initial congestion window size in terms of packet count [default: 10].
--perf disable disk IO.
-h --help Show this screen.
";

Expand All @@ -309,6 +310,7 @@ pub struct ClientArgs {
pub source_port: u16,
pub perform_migration: bool,
pub send_priority_update: bool,
pub perf: bool,
}

impl Args for ClientArgs {
Expand Down Expand Up @@ -386,6 +388,8 @@ impl Args for ClientArgs {

let send_priority_update = args.get_bool("--send-priority-update");

let perf = args.get_bool("--perf");

ClientArgs {
version,
dump_response_path,
Expand All @@ -402,6 +406,7 @@ impl Args for ClientArgs {
source_port,
perform_migration,
send_priority_update,
perf,
}
}
}
Expand All @@ -424,6 +429,7 @@ impl Default for ClientArgs {
source_port: 0,
perform_migration: false,
send_priority_update: false,
perf: false,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/src/bin/quiche-server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn main() {
trace!("GSO detected: {}", enable_gso);

// Create the configuration for the QUIC connections.
let mut config = quiche::Config::new(quiche::PROTOCOL_VERSION).unwrap();
let mut config = quiche::Config::new(quiche::PROTOCOL_VERSION_V1).unwrap();

config.load_cert_chain_from_pem_file(&args.cert).unwrap();
config.load_priv_key_from_pem_file(&args.key).unwrap();
Expand Down
1 change: 1 addition & 0 deletions apps/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ pub fn connect(
args.dump_json,
dgram_sender,
Rc::clone(&output_sink),
args.perf
));

app_proto_selected = true;
Expand Down
6 changes: 5 additions & 1 deletion apps/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,7 @@ pub struct Http3Conn {
dump_json: bool,
dgram_sender: Option<Http3DgramSender>,
output_sink: Rc<RefCell<dyn FnMut(String)>>,
perf: bool,
}

impl Http3Conn {
Expand All @@ -769,6 +770,7 @@ impl Http3Conn {
qpack_blocked_streams: Option<u64>, dump_json: Option<usize>,
dgram_sender: Option<Http3DgramSender>,
output_sink: Rc<RefCell<dyn FnMut(String)>>,
perf: bool,
) -> Box<dyn HttpConn> {
let mut reqs = Vec::new();
for url in urls {
Expand Down Expand Up @@ -850,6 +852,7 @@ impl Http3Conn {
dump_json: dump_json.is_some(),
dgram_sender,
output_sink,
perf,
};

Box::new(h_conn)
Expand Down Expand Up @@ -882,6 +885,7 @@ impl Http3Conn {
dump_json: false,
dgram_sender,
output_sink,
perf: false,
};

Ok(Box::new(h_conn))
Expand Down Expand Up @@ -1263,7 +1267,7 @@ impl HttpConn for Http3Conn {
},

None =>
if !self.dump_json {
if !self.dump_json && !self.perf {
self.output_sink.borrow_mut()(unsafe {
String::from_utf8_unchecked(
buf[..read].to_vec(),
Expand Down
7 changes: 4 additions & 3 deletions quiche/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ use likely_stable::if_likely;


/// The current QUIC wire version.
pub const PROTOCOL_VERSION: u32 = PROTOCOL_VERSION_V3;
pub const PROTOCOL_VERSION: u32 = PROTOCOL_VERSION_V1;

/// Supported QUIC versions.
pub const PROTOCOL_VERSION_V1: u32 = 0x0000_0001;
Expand Down Expand Up @@ -4962,7 +4962,8 @@ impl Connection {
if complete {
self.streams.collect(stream_id, local);
}
// TODO: we might actually want to change this event too?
// TODO: we might actually want to change this event too? in V3,
// the received data isn't moved.
qlog_with_type!(QLOG_DATA_MV, self.qlog, q, {
let ev_data = EventData::DataMoved(qlog::events::quic::DataMoved {
stream_id: Some(stream_id),
Expand All @@ -4981,7 +4982,7 @@ impl Connection {
// Shuffle the incremental stream to the back of the queue.
self.streams.remove_readable(&priority_key);
self.streams.insert_readable(&priority_key);
}
}


Ok((outbuf, read, fin))
Expand Down

0 comments on commit 06c1bb1

Please sign in to comment.