pub struct RecordBatchMemoryTracker { /* private fields */ }Expand description
Like RecordBatchMemoryCounter, but batches can also be released.
Operators that retain batches incrementally and drop them later (sort,
window, sort-merge join, TopK) count a batch when they retain it and
Self::uncount_batch it when they drop it. The tracker keeps a reference
count per buffer: it is charged the largest capacity seen while its count
is positive, and released when its count returns to 0.
Contract: a batch must be uncounted before its buffers are dropped. The tracker identifies buffers by their data-pointer address and does not keep them alive.
───────────────────────┬────────────────────────────
step │ memory_usage()
───────────────────────┼────────────────────────────
count_batch(slice1) │ 4 MB (parent buffer counted)
count_batch(slice2) │ 4 MB (already counted)
uncount_batch(slice1) │ 4 MB (slice2 still uses it)
uncount_batch(slice2) │ 0
───────────────────────┴────────────────────────────Implementations§
Source§impl RecordBatchMemoryTracker
impl RecordBatchMemoryTracker
pub fn new() -> Self
Sourcepub fn count_batch(&mut self, batch: &RecordBatch) -> usize
pub fn count_batch(&mut self, batch: &RecordBatch) -> usize
Count batch, returning the memory used by its buffers that were not
already retained.
Sourcepub fn count_array(&mut self, array: &dyn Array) -> usize
pub fn count_array(&mut self, array: &dyn Array) -> usize
Count array, returning the memory used by its buffers that were not
already retained.
Sourcepub fn count_batch_with_array_overhead(&mut self, batch: &RecordBatch) -> usize
pub fn count_batch_with_array_overhead(&mut self, batch: &RecordBatch) -> usize
Sourcepub fn uncount_batch(&mut self, batch: &RecordBatch) -> usize
pub fn uncount_batch(&mut self, batch: &RecordBatch) -> usize
Release the buffers of batch, returning the bytes freed: the sizes of
buffers no other counted batch retains. Buffers that were never
counted are ignored.
Sourcepub fn uncount_array(&mut self, array: &dyn Array) -> usize
pub fn uncount_array(&mut self, array: &dyn Array) -> usize
Release the buffers of array, returning the bytes freed.
See Self::uncount_batch for semantics.
Sourcepub fn uncount_batch_with_array_overhead(
&mut self,
batch: &RecordBatch,
) -> usize
pub fn uncount_batch_with_array_overhead( &mut self, batch: &RecordBatch, ) -> usize
Inverse of Self::count_batch_with_array_overhead.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Total memory of all retained allocations.
Trait Implementations§
Source§impl Debug for RecordBatchMemoryTracker
impl Debug for RecordBatchMemoryTracker
Auto Trait Implementations§
impl Forget for RecordBatchMemoryTracker
impl Freeze for RecordBatchMemoryTracker
impl Move for RecordBatchMemoryTracker
impl RefUnwindSafe for RecordBatchMemoryTracker
impl Send for RecordBatchMemoryTracker
impl Sync for RecordBatchMemoryTracker
impl Unpin for RecordBatchMemoryTracker
impl UnsafeUnpin for RecordBatchMemoryTracker
impl UnwindSafe for RecordBatchMemoryTracker
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
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