pub struct QueryBufferPool;Expand description
Thread-safe buffer pool for reusing allocations across query executions
Uses thread-local storage to eliminate lock contention. Each thread maintains its own pool of buffers, bounded at MAX_POOLED_BUFFERS entries.
Implementations§
Source§impl QueryBufferPool
impl QueryBufferPool
Sourcepub fn get_row_buffer(&self, min_capacity: usize) -> Vec<Row>
pub fn get_row_buffer(&self, min_capacity: usize) -> Vec<Row>
Get a row buffer from the pool, or create a new one
Returns a buffer with at least min_capacity capacity.
The buffer will be empty but may have allocated capacity.
Sourcepub fn return_row_buffer(&self, buffer: Vec<Row>)
pub fn return_row_buffer(&self, buffer: Vec<Row>)
Return a row buffer to the pool for reuse
The buffer is cleared before being returned to the pool. If the pool is full, the buffer is dropped.
Sourcepub fn get_value_buffer(&self, min_capacity: usize) -> Vec<SqlValue>
pub fn get_value_buffer(&self, min_capacity: usize) -> Vec<SqlValue>
Get a value buffer from the pool, or create a new one
Returns a buffer with at least min_capacity capacity.
The buffer will be empty but may have allocated capacity.
Sourcepub fn return_value_buffer(&self, buffer: Vec<SqlValue>)
pub fn return_value_buffer(&self, buffer: Vec<SqlValue>)
Return a value buffer to the pool for reuse
The buffer is cleared before being returned to the pool. If the pool is full, the buffer is dropped.
Sourcepub fn stats(&self) -> QueryBufferPoolStats
pub fn stats(&self) -> QueryBufferPoolStats
Get statistics about pool usage (for debugging/monitoring)
Returns stats for the current thread’s pool only.
Sourcepub fn clear_thread_local_pools()
pub fn clear_thread_local_pools()
Clear all thread-local buffer pools, releasing memory back to the allocator.
This is useful for benchmarks and long-running processes where memory pressure needs to be reduced between query batches. The pools will automatically refill as needed during subsequent query execution.
§Example
use vibesql_storage::QueryBufferPool;
// Run a batch of queries...
// Clear pools to release memory
QueryBufferPool::clear_thread_local_pools();Trait Implementations§
Source§impl Clone for QueryBufferPool
impl Clone for QueryBufferPool
Source§fn clone(&self) -> QueryBufferPool
fn clone(&self) -> QueryBufferPool
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more