Skip to content

Commit

Permalink
feat: remove fill_cache from getting in rocksdb (#843)
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi authored Nov 13, 2024
1 parent 05466e4 commit 99e3080
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
15 changes: 3 additions & 12 deletions dragonfly-client-storage/src/storage_engine/rocksdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use dragonfly_client_core::{
error::{ErrorType, OrErr},
Error, Result,
};
use rocksdb::{ReadOptions, WriteOptions};
use rocksdb::WriteOptions;
use std::{
ops::Deref,
path::{Path, PathBuf},
Expand Down Expand Up @@ -140,12 +140,7 @@ impl Operations for RocksdbStorageEngine {
#[instrument(skip_all)]
fn get<O: DatabaseObject>(&self, key: &[u8]) -> Result<Option<O>> {
let cf = cf_handle::<O>(self)?;
let mut options = ReadOptions::default();
options.fill_cache(false);

let value = self
.get_cf_opt(cf, key, &options)
.or_err(ErrorType::StorageError)?;
let value = self.get_cf(cf, key).or_err(ErrorType::StorageError)?;
match value {
Some(value) => Ok(Some(O::deserialize_from(&value)?)),
None => Ok(None),
Expand All @@ -156,11 +151,7 @@ impl Operations for RocksdbStorageEngine {
#[instrument(skip_all)]
fn put<O: DatabaseObject>(&self, key: &[u8], value: &O) -> Result<()> {
let cf = cf_handle::<O>(self)?;
let serialized = value.serialized()?;
let mut options = WriteOptions::default();
options.set_sync(true);

self.put_cf_opt(cf, key, serialized, &options)
self.put_cf(cf, key, value.serialized()?)
.or_err(ErrorType::StorageError)?;
Ok(())
}
Expand Down
5 changes: 3 additions & 2 deletions dragonfly-client/src/tracing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub fn init_tracing(

// Setup stdout layer.
let (stdout_writer, stdout_guard) = tracing_appender::non_blocking(std::io::stdout());
guards.push(stdout_guard);

// Initialize stdout layer.
let stdout_filter = if verbose {
Expand All @@ -64,7 +65,6 @@ pub fn init_tracing(
.with_timer(ChronoLocal::rfc_3339())
.pretty()
.with_filter(stdout_filter);
guards.push(stdout_guard);

// Setup file layer.
fs::create_dir_all(log_dir.clone()).expect("failed to create log directory");
Expand All @@ -76,6 +76,8 @@ pub fn init_tracing(
.expect("failed to create rolling file appender");

let (rolling_writer, rolling_writer_guard) = tracing_appender::non_blocking(rolling_appender);
guards.push(rolling_writer_guard);

let file_logging_layer = Layer::new()
.with_writer(rolling_writer)
.with_ansi(false)
Expand All @@ -86,7 +88,6 @@ pub fn init_tracing(
.with_thread_ids(false)
.with_timer(ChronoLocal::rfc_3339())
.compact();
guards.push(rolling_writer_guard);

// Setup env filter for log level.
let env_filter = EnvFilter::try_from_default_env()
Expand Down

0 comments on commit 99e3080

Please sign in to comment.