Module memory

Module memory 

Source
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

  1. Object Pooling: Reuse allocated objects instead of allocating new ones
  2. Compact Types: Smaller type representations for common cases
  3. Inline Storage: Store small data inline to avoid heap allocation
  4. 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§

BufferPool
A pool of reusable String buffers.
MemoryStats
Track memory usage for debugging and optimization.
PoolStats
Statistics for a pool.
PooledBuffer
A buffer borrowed from a pool.
StringPool
A thread-safe pool for interning strings.

Enums§

CompactFilter
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.