enable hashing on large-block indexes

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2025-01-17 20:34:56 +00:00
parent aad42bdaa0
commit bab40a3747
2 changed files with 10 additions and 11 deletions

View file

@ -1,8 +1,4 @@
use conduwuit::{ use conduwuit::{err, utils::math::Expected, Config, Result};
err,
utils::{math::Expected, BoolExt},
Config, Result,
};
use rocksdb::{ use rocksdb::{
BlockBasedIndexType, BlockBasedOptions, BlockBasedPinningTier, Cache, BlockBasedIndexType, BlockBasedOptions, BlockBasedPinningTier, Cache,
DBCompressionType as CompressionType, DataBlockIndexType, LruCacheOptions, Options, DBCompressionType as CompressionType, DataBlockIndexType, LruCacheOptions, Options,
@ -133,10 +129,12 @@ fn table_options(desc: &Descriptor, has_cache: bool) -> BlockBasedOptions {
opts.set_partition_filters(true); opts.set_partition_filters(true);
opts.set_use_delta_encoding(false); opts.set_use_delta_encoding(false);
opts.set_index_type(BlockBasedIndexType::TwoLevelIndexSearch); opts.set_index_type(BlockBasedIndexType::TwoLevelIndexSearch);
opts.set_data_block_index_type(
desc.block_index_hashing opts.set_data_block_index_type(match desc.block_index_hashing {
.map_or(DataBlockIndexType::BinarySearch, || DataBlockIndexType::BinaryAndHash), | None if desc.index_size > 512 => DataBlockIndexType::BinaryAndHash,
); | Some(enable) if enable => DataBlockIndexType::BinaryAndHash,
| Some(_) | None => DataBlockIndexType::BinarySearch,
});
opts opts
} }

View file

@ -34,7 +34,7 @@ pub(crate) struct Descriptor {
pub(crate) compression: CompressionType, pub(crate) compression: CompressionType,
pub(crate) compression_level: i32, pub(crate) compression_level: i32,
pub(crate) bottommost_level: Option<i32>, pub(crate) bottommost_level: Option<i32>,
pub(crate) block_index_hashing: bool, pub(crate) block_index_hashing: Option<bool>,
pub(crate) cache_shards: u32, pub(crate) cache_shards: u32,
} }
@ -60,7 +60,7 @@ pub(crate) static BASE: Descriptor = Descriptor {
compression: CompressionType::Zstd, compression: CompressionType::Zstd,
compression_level: 32767, compression_level: 32767,
bottommost_level: Some(32767), bottommost_level: Some(32767),
block_index_hashing: false, block_index_hashing: None,
cache_shards: 64, cache_shards: 64,
}; };
@ -96,5 +96,6 @@ pub(crate) static SEQUENTIAL_SMALL: Descriptor = Descriptor {
file_size: 1024 * 512, file_size: 1024 * 512,
block_size: 512, block_size: 512,
cache_shards: 64, cache_shards: 64,
block_index_hashing: Some(false),
..SEQUENTIAL ..SEQUENTIAL
}; };