You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: use u64 arithmetic in Pacer instead of u128 (#3594)
* feat: use u64 arithmetic in `Pacer` instead of u128
`Pacer::next` and `bytes_for` used u128 for pacing rate calculations,
causing software-emulated 128-bit division
(`compiler_builtins::u128_by_u64_div_rem`) on every packet send.
The key product in `next` is `rtt_ns * deficit`, where `deficit` is at
most 2 × MTU (~3000 bytes) and a 10-second RTT gives 10^10 ns: product
~3*10^13, far below u64::MAX (1.8*10^19).
The key product in `bytes_for` is `elapsed_ns * cwnd * SPEEDUP`: at
400 Gbps with a 100 ms RTT the inter-packet interval is ~24 ns and the
BDP ~5 GB, giving ~2.4*10^11. Even a full-RTT elapsed (10^8 ns) gives
10^18 < u64::MAX. Beyond that, `saturating_mul` caps the value and
callers clamp to `self.m`.
* Fixes
* Suggestions from @martinthomson
0 commit comments