Module thread_local_pool

Module thread_local_pool 

Source
Expand description

Thread-local memory pools for zero-contention parallel execution

This module provides thread-local buffer pools that eliminate contention in multi-threaded scenarios. Each thread maintains its own pool, avoiding the need for locks or atomic operations.

§Performance Benefits

  • Zero Contention: No locks needed, each thread has its own pool
  • Cache Locality: Thread-local data improves cache hit rates
  • Parallel Scalability: Linear scaling with thread count
  • Low Overhead: ~10-20ns per acquire/release (vs ~100ns+ with locks)

§Usage

use tenrso_exec::executor::thread_local_pool::ThreadLocalPoolManager;

// Enable thread-local pooling
let manager = ThreadLocalPoolManager::new();
manager.enable();

// In parallel code, each thread will use its own pool
let buffer = manager.acquire_f64(&[1000]);
// ... use buffer ...
manager.release_f64(&[1000], buffer);

Structs§

AggregatedPoolStats
Statistics aggregated across all threads
ThreadLocalPoolManager
Manager for thread-local memory pools
ThreadLocalPoolStats
Statistics for a thread-local pool