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: NonZeroUsizeMaximum tracked resident bytes owned by one query across all operators.
batch_rows: NonZeroUsizeMaximum row count in an executor-owned transfer batch.
batch_payload_bytes: NonZeroUsizeMaximum estimated resident bytes in an executor-owned transfer batch.
blocking_operator_bytes: NonZeroUsizeMaximum 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: NonZeroU64Maximum cumulative serialized spill bytes, including merge passes.
max_spill_runs: NonZeroUsizeMaximum cumulative spill runs created, including merge passes.
max_total_spill_bytes: NonZeroU64Maximum live spill bytes shared by all queries using the spill directory.
max_total_spill_runs: NonZeroUsizeMaximum live spill runs shared by all queries using the spill directory.
min_spill_free_bytes: NonZeroU64Free space preserved on the filesystem containing the spill directory.
spill_free_space_probe_interval_bytes: NonZeroU64Reserved bytes between filesystem free-space probes for one spill pool.
spill_orphan_grace_period: DurationMinimum age before a spill file from an earlier process is removed.
spill_directory: PathBufDirectory governed as one shared spill pool.
Implementations§
Source§impl ExecutionMemoryConfig
impl ExecutionMemoryConfig
Sourcepub fn spill_pool_snapshot(&self) -> Result<SpillPoolSnapshot>
pub fn spill_pool_snapshot(&self) -> Result<SpillPoolSnapshot>
Returns process-wide spill usage for this configured directory.
Examples found in repository?
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 graph: None,
167 },
168 ExecutionLimit::unlimited(),
169 &mut |batch| {
170 for binding in batch {
171 let Value::Int(key) = binding.values["key"] else {
172 panic!("missing key")
173 };
174 let Value::Int(ordinal) = binding.values["ordinal"] else {
175 panic!("missing ordinal")
176 };
177 assert!(
178 previous.is_none_or(|previous| previous < (key, ordinal)),
179 "stable ordering changed"
180 );
181 previous = Some((key, ordinal));
182 let Value::List(payload) = &binding.values["payload"] else {
183 panic!("missing payload")
184 };
185 let Value::Map(payload) = &payload[0] else {
186 panic!("missing payload map")
187 };
188 let Value::String(body) = &payload["body"] else {
189 panic!("missing body")
190 };
191 assert_eq!(body.len(), width);
192 measurement.checksum = measurement.checksum.wrapping_add(ordinal as u64);
193 measurement.rows += 1;
194 }
195 Ok(BatchControl::Continue)
196 },
197 )?;
198 assert_eq!(measurement.rows, rows);
199 assert_eq!(measurement.checksum, (rows as u64) * (rows as u64 - 1) / 2);
200 assert_eq!(ledger.snapshot().used_bytes, 0);
201 assert_eq!(memory.spill_pool_snapshot()?.active_bytes, 0);
202 measurement.ledger_peak = ledger.snapshot().peak_bytes;
203 for report in observer.into_reports().blocking_memory {
204 measurement.spill_bytes += report.spilled_bytes;
205 measurement.runs += report.spill_run_count;
206 }
207 if directory.exists() {
208 std::fs::remove_dir_all(directory).unwrap();
209 }
210 Ok(measurement)
211}Trait Implementations§
Source§impl Clone for ExecutionMemoryConfig
impl Clone for ExecutionMemoryConfig
Source§impl Debug for ExecutionMemoryConfig
impl Debug for ExecutionMemoryConfig
Source§impl Default for ExecutionMemoryConfig
impl Default for ExecutionMemoryConfig
impl Eq for ExecutionMemoryConfig
Source§impl PartialEq for ExecutionMemoryConfig
impl PartialEq for ExecutionMemoryConfig
impl StructuralPartialEq for ExecutionMemoryConfig
Auto Trait Implementations§
impl Forget for ExecutionMemoryConfig
impl Freeze for ExecutionMemoryConfig
impl RefUnwindSafe for ExecutionMemoryConfig
impl Send for ExecutionMemoryConfig
impl Sync for ExecutionMemoryConfig
impl Unpin for ExecutionMemoryConfig
impl UnsafeUnpin for ExecutionMemoryConfig
impl UnwindSafe for ExecutionMemoryConfig
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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