diff --git a/.github/workflows/tquic-benchmark.yml b/.github/workflows/tquic-benchmark.yml index 6893acda..55dc22fb 100644 --- a/.github/workflows/tquic-benchmark.yml +++ b/.github/workflows/tquic-benchmark.yml @@ -11,7 +11,7 @@ env: jobs: config: name: Prepare config - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: benchmark_date: ${{ steps.set-benchmark-date.outputs.benchmark_date }} benchmark_impls: ${{ steps.set-implements.outputs.benchmark_impls }} @@ -43,7 +43,7 @@ jobs: build_tquic: name: Build tquic - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: config steps: - uses: actions/checkout@v4 @@ -75,7 +75,7 @@ jobs: build_lsquic: name: Build lsquic - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: config steps: - uses: actions/checkout@v4 @@ -109,7 +109,7 @@ jobs: gen_cert: name: Generate cert - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: config steps: - name: Generate cert @@ -124,7 +124,7 @@ jobs: gen_files: name: Generate files - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: config steps: - name: Generate files @@ -142,7 +142,7 @@ jobs: run_long_conn: name: Run long connection scenario benchmark needs: [ config, build_tquic, build_lsquic, gen_cert, gen_files ] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: matrix: file: [ 15K, 50K, 2M ] @@ -177,7 +177,7 @@ jobs: run_short_conn: name: Run short connection scenario benchmark needs: [ config, build_tquic, build_lsquic, gen_cert, gen_files ] - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - name: Download all uses: actions/download-artifact@v4 @@ -191,7 +191,7 @@ jobs: sh ${impl}_server_bin/start_${impl}.sh pgrep ${impl}_server sleep 1 - ./tquic_client_bin/tquic_client https://tquic_benchmark:4433/file_1K --connect-to 127.0.0.1:4433 --threads 10 --max-concurrent-conns 1 --max-concurrent-requests 1 --max-requests-per-conn 1 --total-requests-per-thread 0 -d ${{ needs.config.outputs.benchmark_duration }} --disable-stateless-reset --send-batch-size 1 --recv-udp-payload-size 1350 --send-udp-payload-size 1350 --log-level OFF > client.log 2>&1 + ./tquic_client_bin/tquic_client https://tquic_benchmark:4433/file_1K --connect-to 127.0.0.1:4433 --threads 10 --max-concurrent-conns 10 --max-concurrent-requests 1 --max-requests-per-conn 1 --total-requests-per-thread 0 -d ${{ needs.config.outputs.benchmark_duration }} --disable-stateless-reset --send-batch-size 1 --recv-udp-payload-size 1350 --send-udp-payload-size 1350 --log-level OFF > client.log 2>&1 cat client.log | grep "finished in" | awk '{print $4}' > benchmark_short_${impl}_1K_10_1.${round}.${{ needs.config.outputs.benchmark_date }} killall ${impl}_server sleep 1 @@ -205,7 +205,7 @@ jobs: retention-days: 90 result: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: [ run_long_conn, run_short_conn ] steps: - name: Download plot tools diff --git a/src/congestion_control/bbr.rs b/src/congestion_control/bbr.rs index 0dcb4bf7..ea8262c8 100644 --- a/src/congestion_control/bbr.rs +++ b/src/congestion_control/bbr.rs @@ -1064,7 +1064,7 @@ impl CongestionController for Bbr { } fn in_recovery(&self, sent_time: Instant) -> bool { - self.recovery_epoch_start.map_or(false, |t| sent_time <= t) + self.recovery_epoch_start.is_some_and(|t| sent_time <= t) } fn in_slow_start(&self) -> bool { diff --git a/src/congestion_control/bbr3.rs b/src/congestion_control/bbr3.rs index 53830c90..e9e66c30 100644 --- a/src/congestion_control/bbr3.rs +++ b/src/congestion_control/bbr3.rs @@ -760,7 +760,7 @@ impl Bbr3 { } fn in_recovery(&self, sent_time: Instant) -> bool { - self.recovery_epoch_start.map_or(false, |t| sent_time <= t) + self.recovery_epoch_start.is_some_and(|t| sent_time <= t) } fn in_slow_start(&self) -> bool { diff --git a/src/congestion_control/cubic.rs b/src/congestion_control/cubic.rs index f65225e8..4e5622f2 100644 --- a/src/congestion_control/cubic.rs +++ b/src/congestion_control/cubic.rs @@ -506,7 +506,7 @@ impl CongestionController for Cubic { } fn in_recovery(&self, sent_time: Instant) -> bool { - self.recovery_epoch_start.map_or(false, |t| sent_time <= t) + self.recovery_epoch_start.is_some_and(|t| sent_time <= t) } fn congestion_window(&self) -> u64 { diff --git a/src/connection/connection.rs b/src/connection/connection.rs index cff570e7..e00adb5c 100644 --- a/src/connection/connection.rs +++ b/src/connection/connection.rs @@ -2996,7 +2996,7 @@ impl Connection { // frame in a packet with the highest level of packet protection to // avoid the packet being discarded. // See RFC 9000 Section 10.2.3 - if self.local_error.as_ref().map_or(false, |e| !e.is_app) { + if self.local_error.as_ref().is_some_and(|e| !e.is_app) { let pkt_type = match self.tls_session.write_level() { Level::Initial => PacketType::Initial, Level::Handshake => PacketType::Handshake, @@ -3073,7 +3073,7 @@ impl Connection { || self.tls_session.is_in_early_data()) && (self.need_send_handshake_done_frame() || self.need_send_new_token_frame() - || self.local_error.as_ref().map_or(false, |e| e.is_app) + || self.local_error.as_ref().is_some_and(|e| e.is_app) || path.need_send_validation_frames(self.is_server) || path.dplpmtud.should_probe() || path.need_send_ping @@ -3094,7 +3094,7 @@ impl Connection { fn need_send_path_unaware_frames(&self) -> bool { self.need_send_handshake_done_frame() || self.need_send_new_token_frame() - || self.local_error.as_ref().map_or(false, |e| e.is_app) + || self.local_error.as_ref().is_some_and(|e| e.is_app) || self.cids.need_send_cid_control_frames() || self.streams.need_send_stream_frames() } diff --git a/src/connection/recovery.rs b/src/connection/recovery.rs index 3d5699cd..21b008ea 100644 --- a/src/connection/recovery.rs +++ b/src/connection/recovery.rs @@ -802,7 +802,7 @@ impl Recovery { space.lost.clear(); space.acked.clear(); - // Reset loss dection timer + // Reset loss detection timer space.time_of_last_sent_ack_eliciting_pkt = None; space.loss_time = None; space.loss_probes = 0; diff --git a/src/connection/stream.rs b/src/connection/stream.rs index 0043d22e..b16aa5da 100644 --- a/src/connection/stream.rs +++ b/src/connection/stream.rs @@ -4731,7 +4731,7 @@ mod tests { // write empty data with fin flag, it should be ok. assert_eq!(stream.send.write(Bytes::new(), true), Ok(0)); - // Shutdown the stream abrubtly, it should be ok. + // Shutdown the stream abruptly, it should be ok. assert_eq!(stream.send.shutdown(), Ok((0, 18))); // Here we call `write` to make sure the stream's fin_off is set. assert_eq!(stream.recv.write(0, Bytes::new(), true), Ok(())); @@ -4939,7 +4939,7 @@ mod tests { assert_eq!(map.get(20).unwrap().recv.fin_off, Some(30)); // 10. Receive a RESET_STREAM frame for a stream which has been closed. - // Shutdown the stream abrubtly, it should be ok. + // Shutdown the stream abruptly, it should be ok. let stream = map.get_or_create(24, false).unwrap(); assert_eq!(stream.send.shutdown(), Ok((0, 0))); // Here we call `write` to make sure the stream's fin_off is set. @@ -5064,7 +5064,7 @@ mod tests { assert_eq!(map.on_stop_sending_frame_received(4, 0), Ok(())); // 5. Receive a STOP_SENDING frame for a stream which has been closed. - // Shutdown the stream abrubtly, it should be ok. + // Shutdown the stream abruptly, it should be ok. let stream = map.get_or_create(24, false).unwrap(); assert_eq!(stream.send.shutdown(), Ok((0, 0))); // Here we call `write` to make sure the stream's fin_off is set. @@ -5134,7 +5134,7 @@ mod tests { assert_eq!(map.on_stop_sending_frame_received(5, 0), Ok(())); // 5. Receive a STOP_SENDING frame for a stream which has been closed. - // Shutdown the stream abrubtly, it should be ok. + // Shutdown the stream abruptly, it should be ok. let stream = map.get_or_create(25, false).unwrap(); assert_eq!(stream.send.shutdown(), Ok((0, 0))); // Here we call `write` to make sure the stream's fin_off is set. diff --git a/src/connection/timer.rs b/src/connection/timer.rs index 8334bbac..8169e1ff 100644 --- a/src/connection/timer.rs +++ b/src/connection/timer.rs @@ -77,7 +77,7 @@ impl TimerTable { /// Check whether the given timer is expired pub fn is_expired(&self, timer: Timer, after: Instant) -> bool { - self.expires[timer as usize].map_or(false, |x| x <= after) + self.expires[timer as usize].is_some_and(|x| x <= after) } } diff --git a/src/endpoint.rs b/src/endpoint.rs index 1dc5035e..3d0919e6 100644 --- a/src/endpoint.rs +++ b/src/endpoint.rs @@ -757,10 +757,7 @@ impl Endpoint { &self.trace_id, ); - let done = match self.sender.on_packets_send(batch) { - Ok(v) => v, - Err(e) => return Err(e), - }; + let done = self.sender.on_packets_send(batch)?; if done == 0 { break; } diff --git a/src/ffi.rs b/src/ffi.rs index d9665a39..b1fb02e2 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -1992,7 +1992,7 @@ pub struct PacketInfo<'a> { dst_len: socklen_t, } -impl<'a> From<&PacketInfo<'a>> for crate::PacketInfo { +impl From<&PacketInfo<'_>> for crate::PacketInfo { fn from(info: &PacketInfo) -> crate::PacketInfo { crate::PacketInfo { src: sock_addr_from_c(info.src, info.src_len), diff --git a/src/h3/h3.rs b/src/h3/h3.rs index f977cd89..7313e57b 100644 --- a/src/h3/h3.rs +++ b/src/h3/h3.rs @@ -175,7 +175,7 @@ impl<'a> HeaderRef<'a> { } } -impl<'a> NameValue for HeaderRef<'a> { +impl NameValue for HeaderRef<'_> { fn name(&self) -> &[u8] { self.0 } diff --git a/src/h3/qpack/huffman.rs b/src/h3/qpack/huffman.rs index 5e27e6fd..9439b1da 100644 --- a/src/h3/qpack/huffman.rs +++ b/src/h3/qpack/huffman.rs @@ -419,7 +419,7 @@ const ENCODE_TABLE: [(usize, u64); 257] = [ ]; /// The multi-level decoding table for huffman decoder. -const DECODE_TABLE: [[(usize, u8, u8); 16]; 256] = [ +static DECODE_TABLE: [[(usize, u8, u8); 16]; 256] = [ // 0 [ // (next-state, byte, flags). diff --git a/src/packet.rs b/src/packet.rs index bb09395d..1a5498e6 100644 --- a/src/packet.rs +++ b/src/packet.rs @@ -494,7 +494,7 @@ fn encrypt_header( /// Decrypt payload of a QUIC packet. /// /// The `pkt_buf` is the raw data of a QUIC packet. -/// The `paylaod_offset` is the offset of packet payload in `pkt_buf`. +/// The `payload_offset` is the offset of packet payload in `pkt_buf`. /// The `payload_len` is the length of pacekt payload (other than the value of Length field). /// The `pkt_num` is the decrypted and decoded packet number. #[allow(unexpected_cfgs)] diff --git a/src/ranges.rs b/src/ranges.rs index b03a6de2..4f1ebfc9 100644 --- a/src/ranges.rs +++ b/src/ranges.rs @@ -307,7 +307,7 @@ pub struct Iter<'a> { set: btree_map::Iter<'a, u64, u64>, } -impl<'a> Iterator for Iter<'a> { +impl Iterator for Iter<'_> { type Item = Range; fn next(&mut self) -> Option> { @@ -316,14 +316,14 @@ impl<'a> Iterator for Iter<'a> { } } -impl<'a> DoubleEndedIterator for Iter<'a> { +impl DoubleEndedIterator for Iter<'_> { fn next_back(&mut self) -> Option> { let (&start, &end) = self.set.next_back()?; Some(start..end) } } -impl<'a> ExactSizeIterator for Iter<'a> { +impl ExactSizeIterator for Iter<'_> { fn len(&self) -> usize { self.set.len() } @@ -335,7 +335,7 @@ pub struct Flatten<'a> { end: u64, } -impl<'a> Iterator for Flatten<'a> { +impl Iterator for Flatten<'_> { type Item = u64; fn next(&mut self) -> Option { @@ -353,7 +353,7 @@ impl<'a> Iterator for Flatten<'a> { } } -impl<'a> DoubleEndedIterator for Flatten<'a> { +impl DoubleEndedIterator for Flatten<'_> { fn next_back(&mut self) -> Option { if self.next == self.end { let (&start, &end) = self.set.next_back()?;