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,
    pub local_storage: LocalStorageConfig,
}
Expand description

“Arq Resizing Strategy”. Defines all parameters necessary to run the arq resizing algorithm.

Fields§

§min_coverage: f64

The minimum overall coverage the DHT seeks to maintain. A coverage of N means that any particular location of the DHT is covered by N nodes. You can also think of this as a “redundancy factor”.

The whole purpose of the arc resizing is for all agents to adjust their arcs so that at least this amount of coverage (redundancy) is obtained at all times.

§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.

§local_storage: LocalStorageConfig

Settings to override the global arc settings, for instance to mandate an always full arc, or an always zero arc

Implementations§

source§

impl ArqStrat

source

pub fn standard(local_storage: LocalStorageConfig) -> Self

Standard arq strat

source

pub fn midline_coverage(&self) -> f64

The midline between min and max coverage

source

pub fn max_coverage(&self) -> f64

The max coverage as expressed by the min coverage and the buffer

source

pub fn buffer_width(&self) -> f64

The width of the buffer range

source

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.

source

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.

source

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

source

pub fn summary(&self) -> String

Get a summary report of this strat in string format

Trait Implementations§

source§

impl Clone for ArqStrat

source§

fn clone(&self) -> ArqStrat

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ArqStrat

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ArqStrat

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<ArqStrat> for PeerStrat

source§

fn from(original: ArqStrat) -> PeerStrat

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more