Skip to content

Commit

Permalink
pref(rocksdb): enable async io for iterators
Browse files Browse the repository at this point in the history
  • Loading branch information
shumkov committed Mar 26, 2024
1 parent d007bed commit 446ffcd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use grovedb_costs::{
storage_cost::key_value_cost::KeyValueStorageCost, ChildrenSizesWithIsSumTree, CostResult,
CostsExt,
};
use rocksdb::{ColumnFamily, DBRawIteratorWithThreadMode, WriteBatchWithTransaction};
use rocksdb::{ColumnFamily, DBRawIteratorWithThreadMode, ReadOptions, WriteBatchWithTransaction};

use super::{make_prefixed_key, PrefixedRocksDbBatch, PrefixedRocksDbRawIterator};
use crate::{
Expand Down Expand Up @@ -232,9 +232,12 @@ impl<'db> StorageContext<'db> for PrefixedRocksDbImmediateStorageContext<'db> {
}

fn raw_iter(&self) -> Self::RawIterator {
let mut opts = ReadOptions::default();
opts.set_async_io(true);

PrefixedRocksDbRawIterator {
prefix: self.prefix,
raw_iterator: self.transaction.raw_iterator(),
raw_iterator: self.transaction.raw_iterator_opt(opts),
}
}
}
7 changes: 5 additions & 2 deletions storage/src/rocksdb_storage/storage_context/context_no_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use grovedb_costs::{
storage_cost::key_value_cost::KeyValueStorageCost, ChildrenSizesWithIsSumTree, CostResult,
CostsExt, OperationCost,
};
use rocksdb::{ColumnFamily, DBRawIteratorWithThreadMode};
use rocksdb::{ColumnFamily, DBRawIteratorWithThreadMode, ReadOptions};

use super::{batch::PrefixedMultiContextBatchPart, make_prefixed_key, PrefixedRocksDbRawIterator};
use crate::{
Expand Down Expand Up @@ -278,9 +278,12 @@ impl<'db> StorageContext<'db> for PrefixedRocksDbStorageContext<'db> {
}

fn raw_iter(&self) -> Self::RawIterator {
let mut opts = ReadOptions::default();
opts.set_async_io(true);

PrefixedRocksDbRawIterator {
prefix: self.prefix,
raw_iterator: self.storage.raw_iterator(),
raw_iterator: self.storage.raw_iterator_opt(opts),
}
}
}
7 changes: 5 additions & 2 deletions storage/src/rocksdb_storage/storage_context/context_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ use grovedb_costs::{
cost_return_on_error, storage_cost::key_value_cost::KeyValueStorageCost,
ChildrenSizesWithIsSumTree, CostResult, CostsExt, OperationCost,
};
use rocksdb::{ColumnFamily, DBRawIteratorWithThreadMode};
use rocksdb::{ColumnFamily, DBRawIteratorWithThreadMode, ReadOptions};

use super::{batch::PrefixedMultiContextBatchPart, make_prefixed_key, PrefixedRocksDbRawIterator};
use crate::{
Expand Down Expand Up @@ -310,9 +310,12 @@ impl<'db> StorageContext<'db> for PrefixedRocksDbTransactionContext<'db> {
}

fn raw_iter(&self) -> Self::RawIterator {
let mut opts = ReadOptions::default();
opts.set_async_io(true);

PrefixedRocksDbRawIterator {
prefix: self.prefix,
raw_iterator: self.transaction.raw_iterator(),
raw_iterator: self.transaction.raw_iterator_opt(opts),
}
}
}

0 comments on commit 446ffcd

Please sign in to comment.