udp: log (info-level) estimated channel memory use

This commit is contained in:
Joakim Frostegård 2024-01-02 16:57:46 +01:00
parent 8ad799042e
commit c4e644cb23
2 changed files with 32 additions and 1 deletions

View file

@ -2,6 +2,7 @@ use std::borrow::Cow;
use std::collections::BTreeMap;
use std::hash::Hash;
use std::io::Write;
use std::mem::size_of;
use std::net::{SocketAddr, SocketAddrV4};
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
@ -101,6 +102,15 @@ pub struct ConnectedResponseWithAddr {
pub addr: CanonicalSocketAddr,
}
impl ConnectedResponseWithAddr {
pub fn estimated_max_size(config: &Config) -> usize {
size_of::<Self>()
+ config.protocol.max_response_peers
* (size_of::<ResponsePeer<Ipv4AddrBytes>>()
+ size_of::<ResponsePeer<Ipv6AddrBytes>>())
}
}
pub struct Recycler;
impl thingbuf::Recycle<ConnectedResponseWithAddr> for Recycler {