From 19f6d9d0e1dd2e40bb710bdc0e876e4f2fc02917 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Mon, 20 Jan 2025 12:12:44 +0000 Subject: [PATCH] add index-compression and auto-readahead to descriptor Signed-off-by: Jason Volk --- src/database/engine/cf_opts.rs | 16 +++++++++++----- src/database/engine/descriptor.rs | 12 ++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/database/engine/cf_opts.rs b/src/database/engine/cf_opts.rs index da636718..1230081c 100644 --- a/src/database/engine/cf_opts.rs +++ b/src/database/engine/cf_opts.rs @@ -83,11 +83,17 @@ fn set_table_options(opts: &mut Options, desc: &Descriptor, cache: Option<&Cache table.disable_cache(); } - opts.set_options_from_string( - "{{block_based_table_factory={num_file_reads_for_auto_readahead=0;\ - max_auto_readahead_size=524288;initial_auto_readahead_size=16384}}}", - ) - .map_err(map_err)?; + let string = format!( + "{{block_based_table_factory={{num_file_reads_for_auto_readahead={0};\ + max_auto_readahead_size={1};initial_auto_readahead_size={2};\ + enable_index_compression={3}}}}}", + desc.auto_readahead_thresh, + desc.auto_readahead_max, + desc.auto_readahead_init, + desc.compressed_index, + ); + + opts.set_options_from_string(&string).map_err(map_err)?; opts.set_block_based_table_factory(&table); diff --git a/src/database/engine/descriptor.rs b/src/database/engine/descriptor.rs index 2c84ac53..6ce8b5ad 100644 --- a/src/database/engine/descriptor.rs +++ b/src/database/engine/descriptor.rs @@ -34,11 +34,15 @@ pub(crate) struct Descriptor { pub(crate) compaction: CompactionStyle, pub(crate) compaction_pri: CompactionPri, pub(crate) compression: CompressionType, + pub(crate) compressed_index: bool, pub(crate) compression_shape: [i32; 7], pub(crate) compression_level: i32, pub(crate) bottommost_level: Option, pub(crate) block_index_hashing: Option, pub(crate) cache_shards: u32, + pub(crate) auto_readahead_thresh: u32, + pub(crate) auto_readahead_init: usize, + pub(crate) auto_readahead_max: usize, } pub(crate) static BASE: Descriptor = Descriptor { @@ -61,11 +65,15 @@ pub(crate) static BASE: Descriptor = Descriptor { compaction: CompactionStyle::Level, compaction_pri: CompactionPri::MinOverlappingRatio, compression: CompressionType::Zstd, + compressed_index: true, compression_shape: [0, 0, 0, 1, 1, 1, 1], compression_level: SENTINEL_COMPRESSION_LEVEL, bottommost_level: Some(SENTINEL_COMPRESSION_LEVEL), block_index_hashing: None, cache_shards: 64, + auto_readahead_thresh: 0, + auto_readahead_init: 1024 * 16, + auto_readahead_max: 1024 * 1024 * 2, }; pub(crate) static RANDOM: Descriptor = Descriptor { @@ -74,6 +82,7 @@ pub(crate) static RANDOM: Descriptor = Descriptor { cache_shards: 128, compression_level: -3, bottommost_level: Some(4), + compressed_index: true, ..BASE }; @@ -86,6 +95,7 @@ pub(crate) static SEQUENTIAL: Descriptor = Descriptor { compression_level: -1, bottommost_level: Some(6), compression_shape: [0, 0, 1, 1, 1, 1, 1], + compressed_index: false, ..BASE }; @@ -100,6 +110,7 @@ pub(crate) static RANDOM_SMALL: Descriptor = Descriptor { compression_level: -4, bottommost_level: Some(1), compression_shape: [0, 0, 0, 0, 0, 1, 1], + compressed_index: false, ..RANDOM }; @@ -114,5 +125,6 @@ pub(crate) static SEQUENTIAL_SMALL: Descriptor = Descriptor { compression_level: -2, bottommost_level: Some(4), compression_shape: [0, 0, 0, 0, 1, 1, 1], + compressed_index: false, ..SEQUENTIAL };