Struct concread::arcache::ARCacheBuilder
source · pub struct ARCacheBuilder { /* private fields */ }
Expand description
A configurable builder to create new concurrent Adaptive Replacement Caches.
Implementations§
source§impl ARCacheBuilder
impl ARCacheBuilder
sourcepub fn set_expected_workload(
self,
total: usize,
threads: usize,
ex_ro_miss: usize,
ex_rw_miss: usize,
read_cache: bool,
) -> Self
pub fn set_expected_workload( self, total: usize, threads: usize, ex_ro_miss: usize, ex_rw_miss: usize, read_cache: bool, ) -> Self
Configure a new ARCache, that derives its size based on your expected workload.
The values are total number of items you want to have in memory, the number of read threads you expect concurrently, the expected average number of cache misses per read operation, and the expected average number of writes or write cache misses per operation. The following formula is assumed:
max + (threads * (max/16))
+ (threads * avg number of misses per op)
+ avg number of writes per transaction
The cache may still exceed your provided total, and inaccurate tuning numbers will yield a situation where you may use too-little ram, or too much. This could be to your read misses exceeding your expected amount causing the queues to have more items in them at a time, or your writes are larger than expected.
If you set ex_ro_miss to zero, no read thread local cache will be configured, but space will still be reserved for channel communication.
sourcepub fn set_size(self, max: usize, read_max: usize) -> Self
pub fn set_size(self, max: usize, read_max: usize) -> Self
Configure a new ARCache, with a capacity of max
main cache items and read_max
Note that due to the way the cache operates, the number of items can and
will exceed max
on a regular basis, so you should consider using set_expected_workload
and specifying your expected workload parameters to have a better derived
cache size.
sourcepub fn set_watermark(self, watermark: usize) -> Self
pub fn set_watermark(self, watermark: usize) -> Self
See ARCache::new_size for more information. This allows manual configuration of the data tracking watermark. To disable this, set to 0. If watermark is greater than max, it will be clamped to max.
sourcepub fn set_reader_quiesce(self, reader_quiesce: bool) -> Self
pub fn set_reader_quiesce(self, reader_quiesce: bool) -> Self
Enable or Disable reader cache quiescing. In some cases this can improve reader performance, at the expense that cache includes or hits may be delayed before acknowledgement. You must MANUALLY run periodic quiesces if you mark this as “false” to disable reader quiescing.