pub struct QueryBudget {
pub query_class: String,
pub ram_bytes_limit: u64,
pub ssd_random_reads_limit: u32,
pub ssd_sequential_bytes_limit: u64,
pub cpu_cycles_limit: u64,
pub latency_target: Duration,
pub recall_target: f32,
pub recall_confidence: f32,
}Expand description
Per-query budget limits derived from SLA targets
Fields§
§query_class: StringQuery class identifier (e.g., “low_latency”, “high_recall”, “balanced”)
ram_bytes_limit: u64Maximum RAM bytes scanned for candidate generation This bounds memory bandwidth consumption
ssd_random_reads_limit: u32Maximum SSD random reads in hot path (ideally 0) Random IO is the main source of p99 variance
ssd_sequential_bytes_limit: u64Maximum SSD sequential bytes for rerank batching Sequential IO is more predictable than random
cpu_cycles_limit: u64Maximum CPU cycles for routing and scan Converted from latency target: cycles = latency_ns * freq_ghz
latency_target: DurationTarget latency SLA (e.g., p99 ≤ 10ms)
recall_target: f32Target recall floor (e.g., recall@10 ≥ 0.95)
recall_confidence: f32Probability of meeting recall target (1 - δ)
Implementations§
Source§impl QueryBudget
impl QueryBudget
Sourcepub fn ssd_random_reads(self, limit: u32) -> Self
pub fn ssd_random_reads(self, limit: u32) -> Self
Set SSD random reads limit
Sourcepub fn ssd_sequential_bytes(self, limit: u64) -> Self
pub fn ssd_sequential_bytes(self, limit: u64) -> Self
Set SSD sequential bytes limit
Sourcepub fn cpu_cycles(self, limit: u64) -> Self
pub fn cpu_cycles(self, limit: u64) -> Self
Set CPU cycles limit
Sourcepub fn latency_target(self, target: Duration) -> Self
pub fn latency_target(self, target: Duration) -> Self
Set latency target
Sourcepub fn recall_target(self, target: f32, confidence: f32) -> Self
pub fn recall_target(self, target: f32, confidence: f32) -> Self
Set recall target
Sourcepub fn from_sla(
query_class: &str,
latency_target: Duration,
recall_target: f32,
hardware: &HardwareProfile,
) -> Self
pub fn from_sla( query_class: &str, latency_target: Duration, recall_target: f32, hardware: &HardwareProfile, ) -> Self
Create budget from SLA parameters
Converts latency SLA into resource budgets:
- Bytes ≤ BW_eff · T
- RandomIO ≤ ⌊T / L_io⌋
Sourcepub fn low_latency() -> Self
pub fn low_latency() -> Self
Predefined budget for low-latency queries (p99 ≤ 5ms)
Sourcepub fn high_recall() -> Self
pub fn high_recall() -> Self
Predefined budget for high-recall queries (p99 ≤ 100ms)
Trait Implementations§
Source§impl Clone for QueryBudget
impl Clone for QueryBudget
Source§fn clone(&self) -> QueryBudget
fn clone(&self) -> QueryBudget
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for QueryBudget
impl RefUnwindSafe for QueryBudget
impl Send for QueryBudget
impl Sync for QueryBudget
impl Unpin for QueryBudget
impl UnsafeUnpin for QueryBudget
impl UnwindSafe for QueryBudget
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more