use cache builder for row and table cache options
add cache check using multi-get path Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
fc1170e12a
commit
96e85adc32
5 changed files with 90 additions and 34 deletions
|
@ -178,7 +178,7 @@ fn get_cache(ctx: &Context, desc: &Descriptor) -> Option<Cache> {
|
|||
.try_into()
|
||||
.expect("u32 to i32 conversion");
|
||||
|
||||
debug_assert!(shard_bits <= 6, "cache shards limited to 64");
|
||||
debug_assert!(shard_bits <= 10, "cache shards probably too large");
|
||||
let mut cache_opts = LruCacheOptions::default();
|
||||
cache_opts.set_num_shard_bits(shard_bits);
|
||||
cache_opts.set_capacity(size);
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
};
|
||||
|
||||
use conduwuit::{debug, utils::math::usize_from_f64, Result, Server};
|
||||
use rocksdb::{Cache, Env};
|
||||
use rocksdb::{Cache, Env, LruCacheOptions};
|
||||
|
||||
use crate::{or_else, pool::Pool};
|
||||
|
||||
|
@ -25,12 +25,21 @@ impl Context {
|
|||
let config = &server.config;
|
||||
let cache_capacity_bytes = config.db_cache_capacity_mb * 1024.0 * 1024.0;
|
||||
|
||||
let row_cache_capacity_bytes = usize_from_f64(cache_capacity_bytes * 0.50)?;
|
||||
let row_cache = Cache::new_lru_cache(row_cache_capacity_bytes);
|
||||
|
||||
let col_shard_bits = 7;
|
||||
let col_cache_capacity_bytes = usize_from_f64(cache_capacity_bytes * 0.50)?;
|
||||
let col_cache = Cache::new_lru_cache(col_cache_capacity_bytes);
|
||||
|
||||
let row_shard_bits = 7;
|
||||
let row_cache_capacity_bytes = usize_from_f64(cache_capacity_bytes * 0.50)?;
|
||||
|
||||
let mut row_cache_opts = LruCacheOptions::default();
|
||||
row_cache_opts.set_num_shard_bits(row_shard_bits);
|
||||
row_cache_opts.set_capacity(row_cache_capacity_bytes);
|
||||
let row_cache = Cache::new_lru_cache_opts(&row_cache_opts);
|
||||
|
||||
let mut col_cache_opts = LruCacheOptions::default();
|
||||
col_cache_opts.set_num_shard_bits(col_shard_bits);
|
||||
col_cache_opts.set_capacity(col_cache_capacity_bytes);
|
||||
let col_cache = Cache::new_lru_cache_opts(&col_cache_opts);
|
||||
let col_cache: BTreeMap<_, _> = [("Shared".to_owned(), col_cache)].into();
|
||||
|
||||
let mut env = Env::new().or_else(or_else)?;
|
||||
|
|
|
@ -67,6 +67,7 @@ pub(crate) static BASE: Descriptor = Descriptor {
|
|||
pub(crate) static RANDOM: Descriptor = Descriptor {
|
||||
compaction_pri: CompactionPri::OldestSmallestSeqFirst,
|
||||
write_size: 1024 * 1024 * 32,
|
||||
cache_shards: 128,
|
||||
..BASE
|
||||
};
|
||||
|
||||
|
@ -75,6 +76,7 @@ pub(crate) static SEQUENTIAL: Descriptor = Descriptor {
|
|||
write_size: 1024 * 1024 * 64,
|
||||
level_size: 1024 * 1024 * 32,
|
||||
file_size: 1024 * 1024 * 2,
|
||||
cache_shards: 128,
|
||||
..BASE
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue