offload remaining db iterator initial seeks on cache miss

consume task budget on cache hit

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-12-18 22:56:53 +00:00 committed by strawberry
parent 14341bb906
commit 98e6c81e49
16 changed files with 199 additions and 131 deletions

View file

@ -1,4 +1,4 @@
use std::{convert, pin::Pin, sync::Arc};
use std::pin::Pin;
use conduwuit::Result;
use futures::{
@ -6,22 +6,15 @@ use futures::{
task::{Context, Poll},
Stream,
};
use rocksdb::{ColumnFamily, ReadOptions};
use super::{keyval_longevity, Cursor, From, State};
use crate::{keyval::KeyVal, Engine};
use super::{keyval_longevity, Cursor, State};
use crate::keyval::KeyVal;
pub(crate) struct Items<'a> {
state: State<'a>,
}
impl<'a> Items<'a> {
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
Self { state: State::new(db, cf, opts) }
}
}
impl<'a> convert::From<State<'a>> for Items<'a> {
impl<'a> From<State<'a>> for Items<'a> {
fn from(state: State<'a>) -> Self { Self { state } }
}
@ -32,9 +25,6 @@ impl<'a> Cursor<'a, KeyVal<'a>> for Items<'a> {
#[inline]
fn seek(&mut self) { self.state.seek_fwd(); }
#[inline]
fn init(self, from: From<'a>) -> Self { Self { state: self.state.init_fwd(from) } }
}
impl<'a> Stream for Items<'a> {

View file

@ -1,4 +1,4 @@
use std::{convert, pin::Pin, sync::Arc};
use std::pin::Pin;
use conduwuit::Result;
use futures::{
@ -6,22 +6,15 @@ use futures::{
task::{Context, Poll},
Stream,
};
use rocksdb::{ColumnFamily, ReadOptions};
use super::{keyval_longevity, Cursor, From, State};
use crate::{keyval::KeyVal, Engine};
use super::{keyval_longevity, Cursor, State};
use crate::keyval::KeyVal;
pub(crate) struct ItemsRev<'a> {
state: State<'a>,
}
impl<'a> ItemsRev<'a> {
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
Self { state: State::new(db, cf, opts) }
}
}
impl<'a> convert::From<State<'a>> for ItemsRev<'a> {
impl<'a> From<State<'a>> for ItemsRev<'a> {
fn from(state: State<'a>) -> Self { Self { state } }
}
@ -32,9 +25,6 @@ impl<'a> Cursor<'a, KeyVal<'a>> for ItemsRev<'a> {
#[inline]
fn seek(&mut self) { self.state.seek_rev(); }
#[inline]
fn init(self, from: From<'a>) -> Self { Self { state: self.state.init_rev(from) } }
}
impl<'a> Stream for ItemsRev<'a> {

View file

@ -1,4 +1,4 @@
use std::{convert, pin::Pin, sync::Arc};
use std::pin::Pin;
use conduwuit::Result;
use futures::{
@ -6,22 +6,15 @@ use futures::{
task::{Context, Poll},
Stream,
};
use rocksdb::{ColumnFamily, ReadOptions};
use super::{slice_longevity, Cursor, From, State};
use crate::{keyval::Key, Engine};
use super::{slice_longevity, Cursor, State};
use crate::keyval::Key;
pub(crate) struct Keys<'a> {
state: State<'a>,
}
impl<'a> Keys<'a> {
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
Self { state: State::new(db, cf, opts) }
}
}
impl<'a> convert::From<State<'a>> for Keys<'a> {
impl<'a> From<State<'a>> for Keys<'a> {
fn from(state: State<'a>) -> Self { Self { state } }
}
@ -33,9 +26,6 @@ impl<'a> Cursor<'a, Key<'a>> for Keys<'a> {
#[inline]
fn seek(&mut self) { self.state.seek_fwd(); }
#[inline]
fn init(self, from: From<'a>) -> Self { Self { state: self.state.init_fwd(from) } }
}
impl<'a> Stream for Keys<'a> {

View file

@ -1,4 +1,4 @@
use std::{convert, pin::Pin, sync::Arc};
use std::pin::Pin;
use conduwuit::Result;
use futures::{
@ -6,22 +6,15 @@ use futures::{
task::{Context, Poll},
Stream,
};
use rocksdb::{ColumnFamily, ReadOptions};
use super::{slice_longevity, Cursor, From, State};
use crate::{keyval::Key, Engine};
use super::{slice_longevity, Cursor, State};
use crate::keyval::Key;
pub(crate) struct KeysRev<'a> {
state: State<'a>,
}
impl<'a> KeysRev<'a> {
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
Self { state: State::new(db, cf, opts) }
}
}
impl<'a> convert::From<State<'a>> for KeysRev<'a> {
impl<'a> From<State<'a>> for KeysRev<'a> {
fn from(state: State<'a>) -> Self { Self { state } }
}
@ -33,9 +26,6 @@ impl<'a> Cursor<'a, Key<'a>> for KeysRev<'a> {
#[inline]
fn seek(&mut self) { self.state.seek_rev(); }
#[inline]
fn init(self, from: From<'a>) -> Self { Self { state: self.state.init_rev(from) } }
}
impl<'a> Stream for KeysRev<'a> {