Skip to main content

ExecutionMemoryConfig

Struct ExecutionMemoryConfig 

Source
pub struct ExecutionMemoryConfig {
Show 13 fields pub query_memory_bytes: NonZeroUsize, pub batch_rows: NonZeroUsize, pub batch_payload_bytes: NonZeroUsize, pub blocking_operator_bytes: NonZeroUsize, pub graph_expansion_budget: Option<GraphExpansionBudget>, pub max_spill_bytes: NonZeroU64, pub max_spill_runs: NonZeroUsize, pub max_total_spill_bytes: NonZeroU64, pub max_total_spill_runs: NonZeroUsize, pub min_spill_free_bytes: NonZeroU64, pub spill_free_space_probe_interval_bytes: NonZeroU64, pub spill_orphan_grace_period: Duration, pub spill_directory: PathBuf,
}

Fields§

§query_memory_bytes: NonZeroUsize

Maximum tracked resident bytes owned by one query across all operators.

§batch_rows: NonZeroUsize

Maximum row count in an executor-owned transfer batch.

§batch_payload_bytes: NonZeroUsize

Maximum estimated resident bytes in an executor-owned transfer batch.

§blocking_operator_bytes: NonZeroUsize

Maximum estimated bytes retained for blocking state, including sort, aggregation, deduplication, graph traversal state and selected top-K. Source reads use the shared query budget independently of this cap.

§graph_expansion_budget: Option<GraphExpansionBudget>

Optional row and cumulative payload limits for each seeded expansion. None adds no cumulative cap; live allocations still obey the operator, batch and shared query budgets, including runtime-admitted reservations.

§max_spill_bytes: NonZeroU64

Maximum cumulative serialized spill bytes, including merge passes.

§max_spill_runs: NonZeroUsize

Maximum cumulative spill runs created, including merge passes.

§max_total_spill_bytes: NonZeroU64

Maximum live spill bytes shared by all queries using the spill directory.

§max_total_spill_runs: NonZeroUsize

Maximum live spill runs shared by all queries using the spill directory.

§min_spill_free_bytes: NonZeroU64

Free space preserved on the filesystem containing the spill directory.

§spill_free_space_probe_interval_bytes: NonZeroU64

Reserved bytes between filesystem free-space probes for one spill pool.

§spill_orphan_grace_period: Duration

Minimum age before a spill file from an earlier process is removed.

§spill_directory: PathBuf

Directory governed as one shared spill pool.

Implementations§

Source§

impl ExecutionMemoryConfig

Source

pub fn spill_pool_snapshot(&self) -> Result<SpillPoolSnapshot>

Returns process-wide spill usage for this configured directory.

Examples found in repository?
examples/spill_resource_probe.rs (line 200)
115fn query(
116    index: usize,
117    rows: usize,
118    width: usize,
119    blocking: usize,
120    barrier: &Barrier,
121    governor: Option<&RuntimeGovernor>,
122) -> Result<Measurement> {
123    let directory =
124        std::env::temp_dir().join(format!("hawdb-spill-probe-{}-{index}", std::process::id()));
125    let memory = ExecutionMemoryConfig {
126        query_memory_bytes: NonZeroUsize::new(16 * 1024 * 1024).unwrap(),
127        blocking_operator_bytes: NonZeroUsize::new(blocking).unwrap(),
128        batch_payload_bytes: NonZeroUsize::new(64 * 1024).unwrap(),
129        max_spill_runs: NonZeroUsize::new(4096).unwrap(),
130        max_total_spill_runs: NonZeroUsize::new(16384).unwrap(),
131        max_spill_bytes: NonZeroU64::new(1024 * 1024 * 1024).unwrap(),
132        min_spill_free_bytes: NonZeroU64::MIN,
133        spill_directory: directory.clone(),
134        ..ExecutionMemoryConfig::default()
135    };
136    let permit = governor.map(|governor| {
137        governor
138            .try_admit(RuntimeWorkRequest::foreground_query(16 * 1024 * 1024, 0))
139            .unwrap()
140    });
141    let task = permit
142        .as_ref()
143        .map(|permit| permit.bind_task_context(RuntimeTaskContext::default()));
144    let ledger = QueryMemoryLedger::for_query(&memory, task.as_ref())?;
145    let observer = QueryExecutionObserver::default();
146    let catalog = Catalog::default();
147    let items = [SortItem {
148        key: SortKey::Column("key".into()),
149        direction: SortDirection::Asc,
150    }];
151    let mut source = Rows { count: rows, width };
152    let mut measurement = Measurement::default();
153    let mut previous = None;
154    barrier.wait();
155    barrier.wait();
156    stream_sort_batches(
157        &PhysicalPlan::EmptyExec,
158        &items,
159        &mut source,
160        BatchExecutionContext {
161            catalog: &catalog,
162            memory: &memory,
163            memory_ledger: &ledger,
164            task_context: task.as_ref(),
165            observer: &observer,
166        },
167        ExecutionLimit::unlimited(),
168        &mut |batch| {
169            for binding in batch {
170                let Value::Int(key) = binding.values["key"] else {
171                    panic!("missing key")
172                };
173                let Value::Int(ordinal) = binding.values["ordinal"] else {
174                    panic!("missing ordinal")
175                };
176                assert!(
177                    previous.is_none_or(|previous| previous < (key, ordinal)),
178                    "stable ordering changed"
179                );
180                previous = Some((key, ordinal));
181                let Value::List(payload) = &binding.values["payload"] else {
182                    panic!("missing payload")
183                };
184                let Value::Map(payload) = &payload[0] else {
185                    panic!("missing payload map")
186                };
187                let Value::String(body) = &payload["body"] else {
188                    panic!("missing body")
189                };
190                assert_eq!(body.len(), width);
191                measurement.checksum = measurement.checksum.wrapping_add(ordinal as u64);
192                measurement.rows += 1;
193            }
194            Ok(BatchControl::Continue)
195        },
196    )?;
197    assert_eq!(measurement.rows, rows);
198    assert_eq!(measurement.checksum, (rows as u64) * (rows as u64 - 1) / 2);
199    assert_eq!(ledger.snapshot().used_bytes, 0);
200    assert_eq!(memory.spill_pool_snapshot()?.active_bytes, 0);
201    measurement.ledger_peak = ledger.snapshot().peak_bytes;
202    for report in observer.into_reports().blocking_memory {
203        measurement.spill_bytes += report.spilled_bytes;
204        measurement.runs += report.spill_run_count;
205    }
206    if directory.exists() {
207        std::fs::remove_dir_all(directory).unwrap();
208    }
209    Ok(measurement)
210}

Trait Implementations§

Source§

impl Clone for ExecutionMemoryConfig

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExecutionMemoryConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExecutionMemoryConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for ExecutionMemoryConfig

Source§

impl PartialEq for ExecutionMemoryConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ExecutionMemoryConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> RuntimeIoWavePermit for T
where T: Debug + Send,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.