Enum ResizeMode

Source
pub enum ResizeMode {
    Incremental(usize),
    Blocking,
}
Expand description

Resize behavior for a HashMap.

Hash maps must resize when the underlying table becomes full, migrating all key and value pairs to a new table. This type allows you to configure the resizing behavior when passed to HashMapBuilder::resize_mode.

Variants§

§

Incremental(usize)

Writers copy a constant number of key/value pairs to the new table before making progress.

Incremental resizes avoids latency spikes that can occur when insert operations have to resize a large table. However, they reduce parallelism during the resize and so can reduce overall throughput. Incremental resizing also means reads or write operations during an in-progress resize may have to search both the current and new table before succeeding, trading off median latency during a resize for tail latency.

This is the default resize mode, with a chunk size of 64.

§

Blocking

All writes to the map must wait till the resize completes before making progress.

Blocking resizes tend to be better in terms of throughput, especially in setups with multiple writers that can perform the resize in parallel. However, they can lead to latency spikes for insert operations that have to resize large tables.

If insert latency is not a concern, such as if the keys in your map are stable, enabling blocking resizes may yield better performance.

Blocking resizing may also be a better option if you rely heavily on iteration or similar operations, as they require completing any in-progress resizes for consistency.

Trait Implementations§

Source§

impl Debug for ResizeMode

Source§

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

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

impl Default for ResizeMode

Source§

fn default() -> Self

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

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.