pub struct ReplayFilterConfig {
pub max_tracked_packets: usize,
pub shards: usize,
}Expand description
Configuration of the TagReplayFilter.
The two fields are validated together: shards must be a power of two in range, max_tracked_packets must be
at least MIN_TRACKED_PACKETS, and the capacity must leave every shard at least MIN_CAPACITY_PER_SHARD
slots, i.e. max_tracked_packets >= shards * MIN_CAPACITY_PER_SHARD. That last condition is what the field-wise
ranges cannot express on their own - the floor capacity together with the shard ceiling satisfies both of them
yet leaves a shard with a single slot, which rotates on every distinct token.
Fields§
§max_tracked_packets: usizeNumber of tokens the filter remembers per generation, across all shards.
This is the capacity of one generation, split evenly across the shards, and retention is per shard: a
token stays known until its shard has taken max_tracked_packets / shards further distinct tokens, twice
over (once to retire it, once more to drop the retired generation). So a token survives roughly this many
total inserts only if traffic spreads evenly across shards - which a keyed shard hash makes the expected
case, but it is not a hard global bound. Must leave every shard at least MIN_CAPACITY_PER_SHARD slots,
i.e. be at least shards * MIN_CAPACITY_PER_SHARD (and at least MIN_TRACKED_PACKETS).
At the default false-positive rate the bitmap costs roughly three bytes per token per generation, so a decoder ultimately holds about this many megabytes, twice over once a shard has rotated. Generations are allocated on first insertion, so the footprint grows with traffic rather than being paid at construction; at the default it reaches a little under 32 MB per decoder, rising to about 63 MB after every shard has rotated once.
Default is 10 000 000.
shards: usizeNumber of independent shards.
Each shard has its own generation state and lock, so this divides both the memory high-water mark and the lock contention. It must be a power of two, which the validator enforces so that shard selection is a mask rather than a division.
Default is 64.
Trait Implementations§
Source§impl Clone for ReplayFilterConfig
impl Clone for ReplayFilterConfig
Source§fn clone(&self) -> ReplayFilterConfig
fn clone(&self) -> ReplayFilterConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ReplayFilterConfig
Source§impl Debug for ReplayFilterConfig
impl Debug for ReplayFilterConfig
Source§impl Default for ReplayFilterConfig
impl Default for ReplayFilterConfig
impl Eq for ReplayFilterConfig
Source§impl PartialEq for ReplayFilterConfig
impl PartialEq for ReplayFilterConfig
impl StructuralPartialEq for ReplayFilterConfig
Source§impl Validate for ReplayFilterConfig
impl Validate for ReplayFilterConfig
Auto Trait Implementations§
impl Freeze for ReplayFilterConfig
impl RefUnwindSafe for ReplayFilterConfig
impl Send for ReplayFilterConfig
impl Sync for ReplayFilterConfig
impl Unpin for ReplayFilterConfig
impl UnsafeUnpin for ReplayFilterConfig
impl UnwindSafe for ReplayFilterConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more