BlockEngineBuilder

Struct BlockEngineBuilder 

Source
pub struct BlockEngineBuilder<K, V, P>{ /* private fields */ }
Expand description

Builder for the block-based disk cache engine.

The block-based disk cache engine is suitable for general cache entries with size from 2K to hundreds of MiBs.

Each cache entry will be aligned to a multiplier of 4K on disk, hence too small cache entries will lead to heavy internal fragmentation.

The disk cache evicts cache entries in block unit.

Implementations§

Source§

impl<K, V, P> BlockEngineBuilder<K, V, P>

Source

pub fn new(device: Arc<dyn Device>) -> BlockEngineBuilder<K, V, P>

Create a new block-based disk cache engine builder with default configurations.

Source

pub fn with_block_size(self, block_size: usize) -> BlockEngineBuilder<K, V, P>

Set the block size for the block-based disk cache engine.

Block is the minimal cache eviction unit for the block-based disk cache, its size also limits the max cacheable entry size.

The block size must be 4K-aligned. the given value is not 4K-aligned, it will be automatically aligned up.

Default: 16 MiB.

Source

pub fn with_indexer_shards( self, indexer_shards: usize, ) -> BlockEngineBuilder<K, V, P>

Set the shard num of the indexer. Each shard has its own lock.

Default: 64.

Source

pub fn with_recover_concurrency( self, recover_concurrency: usize, ) -> BlockEngineBuilder<K, V, P>

Set the recover concurrency for the disk cache store.

Default: 8.

Source

pub fn with_flushers(self, flushers: usize) -> BlockEngineBuilder<K, V, P>

Set the flusher count for the disk cache store.

The flusher count limits how many blocks can be concurrently written.

Default: 1.

Source

pub fn with_admission_filter( self, filter: StorageFilter, ) -> BlockEngineBuilder<K, V, P>

Set the admission filter for th disk cache store.

The admission filter is used to pick the entries that can be inserted into the disk cache store.

Default: Admit all.

Source

pub fn with_reclaimers(self, reclaimers: usize) -> BlockEngineBuilder<K, V, P>

Set the reclaimer count for the disk cache store.

The reclaimer count limits how many blocks can be concurrently reclaimed.

Default: 1.

Source

pub fn with_buffer_pool_size( self, buffer_pool_size: usize, ) -> BlockEngineBuilder<K, V, P>

Set the total flush buffer pool size.

Each flusher shares a volume at threshold / flushers.

If the buffer of the flush queue exceeds the threshold, the further entries will be ignored.

Default: 16 MiB.

Source

pub fn with_blob_index_size( self, blob_index_size: usize, ) -> BlockEngineBuilder<K, V, P>

Set the blob index size for each blob.

A larger blob index size can hold more blob entries, but it will also increase the io size of each blob part write.

NOTE: The size will be aligned up to a multiplier of 4K.

Default: 4 KiB

Source

pub fn with_submit_queue_size_threshold( self, submit_queue_size_threshold: usize, ) -> BlockEngineBuilder<K, V, P>

Set the submit queue size threshold.

If the total entry estimated size in the submit queue exceeds the threshold, the further entries will be ignored.

Default: buffer_pool_size * 2.

Source

pub fn with_clean_block_threshold( self, clean_block_threshold: usize, ) -> BlockEngineBuilder<K, V, P>

Set the clean block threshold for the disk cache store.

The reclaimers only work when the clean block count is equal to or lower than the clean block threshold.

Default: the same value as the reclaimers.

Source

pub fn with_eviction_pickers( self, eviction_pickers: Vec<Box<dyn EvictionPicker>>, ) -> BlockEngineBuilder<K, V, P>

Set the eviction pickers for th disk cache store.

The eviction picker is used to pick the block to reclaim.

The eviction pickers are applied in order. If the previous eviction picker doesn’t pick any block, the next one will be applied.

If no eviction picker picks a block, a block will be picked randomly.

Default: [ invalid ratio picker { threshold = 0.8 }, fifo picker ]

Source

pub fn with_reinsertion_filter( self, filter: StorageFilter, ) -> BlockEngineBuilder<K, V, P>

Set the reinsertion filter for th disk cache store.

The reinsertion filter is used to pick the entries that can be reinsertion into the disk cache store while reclaiming.

Note: Only extremely important entries should be picked. If too many entries are picked, both insertion and reinsertion will be stuck.

Default: Reject all.

Source

pub fn with_tombstone_log(self, enable: bool) -> BlockEngineBuilder<K, V, P>

Enable the tombstone log.

For updatable cache, either the tombstone log or crate::engine::RecoverMode::None must be enabled to prevent from the phantom entries after reopen.

Source

pub async fn build( self: Box<BlockEngineBuilder<K, V, P>>, __arg1: EngineBuildContext, ) -> Result<Arc<BlockEngine<K, V, P>>, Error>

Build the block-based disk cache engine with the given configurations.

Trait Implementations§

Source§

impl<K, V, P> Debug for BlockEngineBuilder<K, V, P>

Source§

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

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

impl<K, V, P> EngineConfig<K, V, P> for BlockEngineBuilder<K, V, P>

Source§

fn build( self: Box<BlockEngineBuilder<K, V, P>>, ctx: EngineBuildContext, ) -> Pin<Box<dyn Future<Output = Result<Arc<dyn Engine<K, V, P>>, Error>> + Send>>

Build the engine with the given configurations.
Source§

fn boxed(self) -> Box<Self>
where Self: Sized,

Box the builder.

Auto Trait Implementations§

§

impl<K, V, P> Freeze for BlockEngineBuilder<K, V, P>

§

impl<K, V, P> !RefUnwindSafe for BlockEngineBuilder<K, V, P>

§

impl<K, V, P> Send for BlockEngineBuilder<K, V, P>

§

impl<K, V, P> Sync for BlockEngineBuilder<K, V, P>

§

impl<K, V, P> Unpin for BlockEngineBuilder<K, V, P>
where K: Unpin, V: Unpin, P: Unpin,

§

impl<K, V, P> !UnwindSafe for BlockEngineBuilder<K, V, P>

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Scope for T

Source§

fn with<F, R>(self, f: F) -> R
where Self: Sized, F: FnOnce(Self) -> R,

Scoped with ownership.
Source§

fn with_ref<F, R>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Scoped with reference.
Source§

fn with_mut<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Scoped with mutable reference.
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.
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
Source§

impl<T> Value for T
where T: Send + Sync + 'static,