Re-add checked arithmetic to the packet counter. It may not solve the spike problem, but it should be there anyway.

This commit is contained in:
Herbert Wolverson 2023-07-11 14:46:27 +00:00
parent da16691306
commit acabdc7ff2

View File

@ -193,8 +193,15 @@ impl ThroughputTracker {
#[inline(always)] #[inline(always)]
fn add_atomic_tuple(tuple: &(AtomicU64, AtomicU64), n: (u64, u64)) { fn add_atomic_tuple(tuple: &(AtomicU64, AtomicU64), n: (u64, u64)) {
tuple.0.fetch_add(n.0, std::sync::atomic::Ordering::Relaxed); let mut n0 = tuple.0.load(std::sync::atomic::Ordering::Relaxed);
tuple.1.fetch_add(n.1, std::sync::atomic::Ordering::Relaxed); if let Some(n) = n0.checked_add(n.0) {
tuple.0.store(n, std::sync::atomic::Ordering::Relaxed);
}
let mut n1 = tuple.1.load(std::sync::atomic::Ordering::Relaxed);
if let Some(n) = n1.checked_add(n.1) {
tuple.1.store(n, std::sync::atomic::Ordering::Relaxed);
}
} }
pub(crate) fn update_totals(&self) { pub(crate) fn update_totals(&self) {