Expand description
Memory optimization utilities for prax-query.
This module provides memory-efficient alternatives and pooling mechanisms to reduce allocation counts and peak memory usage.
§Optimization Strategies
- Object Pooling: Reuse allocated objects instead of allocating new ones
- Compact Types: Smaller type representations for common cases
- Inline Storage: Store small data inline to avoid heap allocation
- String Deduplication: Share identical strings via interning
§Example
use prax_query::memory::{StringPool, CompactFilter};
use std::sync::Arc;
// Reuse strings from a pool
let pool = StringPool::new();
let s1 = pool.intern("id");
let s2 = pool.intern("id");
// s1 and s2 point to the same allocation
// Use compact filters for simple cases
let filter = CompactFilter::eq_int(Arc::from("id"), 42);Structs§
- Buffer
Pool - A pool of reusable String buffers.
- Memory
Stats - Track memory usage for debugging and optimization.
- Pool
Stats - Statistics for a pool.
- Pooled
Buffer - A buffer borrowed from a pool.
- String
Pool - A thread-safe pool for interning strings.
Enums§
- Compact
Filter - A compact filter representation for simple equality filters.
Statics§
- GLOBAL_
BUFFER_ POOL - Global buffer pool for SQL generation.
- GLOBAL_
STRING_ POOL - Global string pool for common field names.
Functions§
- get_
buffer - Get a buffer from the global pool.
- intern
- Intern a string using the global pool.