webrtc-rs / webrtc

A pure Rust implementation of WebRTC
https://webrtc.rs
Apache License 2.0
3.95k stars 347 forks source link

use the new feature of the crc crate for more throughput in sctp #569

Closed KillingSpark closed 2 months ago

KillingSpark commented 2 months ago

The crc crate has released finally released a new version featuring an improved algorithm that greatly increases performance. The new algorithm uses a few Kb more of lookup tables which is why it has to be enabled explicitly. This PR bumps the version of the crc crate to the required level and enables that new algorithm.

Crc performance is a significant bottleneck in the sctp throughput as showcased by the throughput example:

Before:

Throughput: 67238910 Bytes/s, 1026 pkts, 1026 loops
Send 1031 pkts
Throughput: 68025330 Bytes/s, 1038 pkts, 1038 loops
Send 1038 pkts
Throughput: 68484075 Bytes/s, 1045 pkts, 1045 loops
Send 1049 pkts
Throughput: 68353005 Bytes/s, 1043 pkts, 1043 loops
Send 1046 pkts
Throughput: 68746215 Bytes/s, 1049 pkts, 1049 loops
Send 1050 pkts
Throughput: 67632120 Bytes/s, 1032 pkts, 1032 loops
Send 1037 pkts

After:

Throughput: 85523175 Bytes/s, 1305 pkts, 1305 loops
Send 1311 pkts
Throughput: 86768340 Bytes/s, 1324 pkts, 1324 loops
Send 1325 pkts
Throughput: 86899410 Bytes/s, 1326 pkts, 1326 loops
Send 1328 pkts
Throughput: 86440665 Bytes/s, 1319 pkts, 1319 loops
Send 1319 pkts
Throughput: 86637270 Bytes/s, 1322 pkts, 1322 loops
Send 1323 pkts
Throughput: 86899410 Bytes/s, 1326 pkts, 1326 loops
Send 1328 pkts

Edit: About the formatting CI: I can only reproduce one of the two fixes locally, but that one isn't related to this PR. The one related to this PR I can't reproduce locally (cargo fmt just doesn't produce this output for me...?!)

Do you want me to fix these two? I'd be glad to do it but I don't want to clutter the PR either

codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 61.50%. Comparing base (dcfefd7) to head (14f02f5).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #569 +/- ## ========================================== - Coverage 61.61% 61.50% -0.12% ========================================== Files 531 531 Lines 48885 48751 -134 Branches 12289 12297 +8 ========================================== - Hits 30120 29983 -137 - Misses 9575 9581 +6 + Partials 9190 9187 -3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

rainliu commented 2 months ago

please fix cargo fmt check