Struct holochain::prelude::kitsune_p2p::dependencies::kitsune_p2p_types::dht::arq::ArqStrat
pub struct ArqStrat {
pub min_coverage: f64,
pub buffer: f64,
pub max_power_diff: u8,
pub slacker_ratio: f64,
pub power_std_dev_threshold: f64,
}
Expand description
“Arq Resizing Strategy”. Defines all parameters necessary to run the arq resizing algorithm.
Fields§
§min_coverage: f64
The minimum coverage the DHT seeks to maintain.
This is the whole purpose for arc resizing.
buffer: f64
A multiplicative factor of the min coverage which defines a max. coverage. We want coverage to be between the min and max coverage. This is expressed in terms of a value > 0 and < 1. For instance, a min coverage of 50 with a buffer of 0.2 implies a max coverage of 60.
max_power_diff: u8
If the difference between the arq’s power and the median power of all peer arqs (including this one) is greater than this diff, then don’t requantize: just keep growing or shrinking past the min/max chunks value.
This parameter determines how likely it is for there to be a difference in chunk sizes between two agents’ arqs. It establishes the tradeoff between the size of payloads that must be sent and the extra coordination or computation that must be performed to accomodate agents whose power is lower than ours.
This parameter is also what allows an arq to shrink to zero in a reasonable number of steps. Without this limit on power diff, we would keep requantizing until the power was 0 before shrinking to the empty arc. We may shrink to zero if our neighborhood is significantly over-covered, which can happen if a number of peers decide to keep their coverage higher than the ideal equilibrium value.
Note that this parameter does not guarantee that any agent’s arq will have a power +/- this diff from our power, but we may decide to choose not to gossip with agents whose power falls outside the range defined by this diff. TODO: do this.
slacker_ratio: f64
If at any time the number of peers seen by a node is less than the extrapolated coverage scaled by this factor, then we assume that we need to grow our arc so that we can see more peers. In other words, we are “slacking” if at any time: num_peers < extrapolated_coverage * slack_factor
If this is set too high, it may prevent arcs from legitimately shrinking. If set too low, it will hamper the ability for extremely small arcs to reach a proper size
power_std_dev_threshold: f64
If the standard deviation of the powers of each arq in this view is greater than this threshold, then we might do something different when it comes to our decision to requantize. For now, just print a warning.
TODO: this can probably be expressed in terms of max_power_diff
.
Implementations§
§impl ArqStrat
impl ArqStrat
pub fn from_params(min_coverage: f64) -> ArqStrat
pub fn from_params(min_coverage: f64) -> ArqStrat
Constructor
pub fn midline_coverage(&self) -> f64
pub fn midline_coverage(&self) -> f64
The midline between min and max coverage
pub fn max_coverage(&self) -> f64
pub fn max_coverage(&self) -> f64
The max coverage as expressed by the min coverage and the buffer
pub fn buffer_width(&self) -> f64
pub fn buffer_width(&self) -> f64
The width of the buffer range
pub fn min_chunks(&self) -> u32
pub fn min_chunks(&self) -> u32
The lower bound of number of chunks to maintain in an arq. When the chunk count falls below this number, halve the chunk size.
pub fn max_chunks(&self) -> u32
pub fn max_chunks(&self) -> u32
The upper bound of number of chunks to maintain in an arq. When the chunk count exceeds this number, double the chunk size.
This is expressed in terms of min_chunks because we want this value to always be odd – this is because when growing the arq, we need to downshift the power, and we can only downshift losslessly if the count is even, and the most common case of exceeding the max_chunks is is to exceed the max_chunks by 1, which would be an even number.
pub fn max_chunks_log2(&self) -> u8
pub fn max_chunks_log2(&self) -> u8
The floor of the log2 of the max_chunks. For the default of 15, floor(log2(15)) = 3
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for ArqStrat
impl Send for ArqStrat
impl Sync for ArqStrat
impl Unpin for ArqStrat
impl UnwindSafe for ArqStrat
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
§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> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.