From f5182d2ca9aeb0445aa5a976ef44897854b87282 Mon Sep 17 00:00:00 2001 From: Moritz Borcherding Date: Wed, 15 May 2024 14:54:18 +0200 Subject: [PATCH 1/2] use the new feature of the crc crate for more throughput in sctp --- sctp/Cargo.toml | 2 +- sctp/src/util.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sctp/Cargo.toml b/sctp/Cargo.toml index 1db69da33..f03be0a61 100644 --- a/sctp/Cargo.toml +++ b/sctp/Cargo.toml @@ -27,7 +27,7 @@ tokio = { version = "1.32.0", features = [ ] } bytes = "1" rand = "0.8" -crc = "3" +crc = "3.2.1" async-trait = "0.1" log = "0.4" thiserror = "1" diff --git a/sctp/src/util.rs b/sctp/src/util.rs index 6e18577b9..5c3739ff7 100644 --- a/sctp/src/util.rs +++ b/sctp/src/util.rs @@ -1,5 +1,5 @@ use bytes::Bytes; -use crc::{Crc, CRC_32_ISCSI}; +use crc::{Crc, CRC_32_ISCSI, Table}; pub(crate) const PADDING_MULTIPLE: usize = 4; @@ -11,7 +11,7 @@ pub(crate) fn get_padding_size(len: usize) -> usize { /// We need to use it for the checksum and don't want to allocate/clear each time. pub(crate) static FOUR_ZEROES: Bytes = Bytes::from_static(&[0, 0, 0, 0]); -pub(crate) const ISCSI_CRC: Crc = Crc::::new(&CRC_32_ISCSI); +pub(crate) const ISCSI_CRC: Crc> = Crc::>::new(&CRC_32_ISCSI); /// Fastest way to do a crc32 without allocating. pub(crate) fn generate_packet_checksum(raw: &Bytes) -> u32 { From 14f02f53eddd6dd5a67a7cc42b4ad442bf76cbd4 Mon Sep 17 00:00:00 2001 From: Moritz Borcherding Date: Wed, 15 May 2024 15:04:26 +0200 Subject: [PATCH 2/2] changelog entry --- sctp/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sctp/CHANGELOG.md b/sctp/CHANGELOG.md index 1213cf27e..ee7acd552 100644 --- a/sctp/CHANGELOG.md +++ b/sctp/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +* Use the new algorithm in crc crate for better throughput [#569](https://github.com/webrtc-rs/webrtc/pull/569) + ## v0.8.0 * Fix 'attempt to add with overflow' panic in dev profile [#393](https://github.com/webrtc-rs/webrtc/pull/393)