Skip to content

Commit f0874b1

Browse files
committed
add more rocksdb options
1 parent 8f5a9bf commit f0874b1

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
publish = true
33
name = "llm-weaver"
4-
version = "0.2.0"
4+
version = "0.2.1"
55
edition = "2021"
66
description = "Manage long conversations with any LLM"
77
readme = "README.md"

src/storage/rocksdb.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use async_trait::async_trait;
2-
use rocksdb::{ColumnFamilyDescriptor, OptimisticTransactionDB, Options, Transaction};
2+
use rocksdb::{
3+
ColumnFamilyDescriptor, DBCompressionType, OptimisticTransactionDB, Options, Transaction,
4+
};
35
use serde::{de::DeserializeOwned, Serialize};
46
use std::{
57
fmt::Debug,
@@ -44,17 +46,25 @@ impl RocksDbBackend {
4446
opts.increase_parallelism(num_cpus::get() as i32);
4547
opts.set_max_background_jobs(4);
4648
opts.set_max_write_buffer_number(3);
47-
opts.set_write_buffer_size(8 * 1024 * 1024 * 1024);
49+
opts.set_write_buffer_size(64 * 1024 * 1024); // 64MB
4850
opts.set_target_file_size_base(64 * 1024 * 1024); // 64MB
51+
opts.set_level_compaction_dynamic_level_bytes(true);
52+
opts.set_max_bytes_for_level_base(256 * 1024 * 1024); // 256MB
53+
opts.set_bloom_locality(1);
54+
opts.set_compression_type(DBCompressionType::Lz4);
55+
opts.set_periodic_compaction_seconds(86400); // 24 hours
56+
57+
let mut cf_opts = Options::default();
58+
cf_opts.set_compression_type(DBCompressionType::Lz4);
59+
cf_opts.set_bottommost_compression_type(DBCompressionType::Zstd);
4960

5061
let cf_descriptors = vec![
51-
ColumnFamilyDescriptor::new(INSTANCE_INDEX_CF, Options::default()),
52-
ColumnFamilyDescriptor::new(TAPESTRY_METADATA_CF, Options::default()),
53-
ColumnFamilyDescriptor::new(TAPESTRY_FRAGMENT_CF, Options::default()),
62+
ColumnFamilyDescriptor::new(INSTANCE_INDEX_CF, cf_opts.clone()),
63+
ColumnFamilyDescriptor::new(TAPESTRY_METADATA_CF, cf_opts.clone()),
64+
ColumnFamilyDescriptor::new(TAPESTRY_FRAGMENT_CF, cf_opts),
5465
];
5566

5667
let db_path = std::env::var("ROCKSDB_PATH").unwrap_or_else(|_| "rocksdb-data".to_string());
57-
5868
OptimisticTransactionDB::open_cf_descriptors(&opts, db_path, cf_descriptors)
5969
.map(Arc::new)
6070
.map_err(|e| StorageError::DatabaseError(e.to_string()).into())

0 commit comments

Comments
 (0)