pub struct EntropyCache { /* private fields */ }Expand description
Entropy result cache for deterministic price sequences (Issue #96 Task #117)
Caches permutation entropy results to avoid redundant computation on identical price sequences. Uses quick_cache::sync::Cache for production-grade LRU eviction with O(1) lookup. Useful for consolidation periods where price sequences repeat frequently.
§Performance Impact
- Consolidation periods: 1.5-2.5x speedup (high repetition)
- Trending markets: 1.0-1.2x speedup (low repetition)
- Memory: Automatic LRU eviction (max 128 entries by default)
§Implementation
- Uses quick_cache::sync::Cache with automatic LRU eviction (Issue #96 Task #125)
- Hash function: foldhash (captures exact floating-point values, 20-40% faster than ahash)
- Thread-safe via quick_cache’s internal locking
- Metrics: Cache hit/miss/eviction tracking (Issue #96 Task #135)
Implementations§
Source§impl EntropyCache
impl EntropyCache
Sourcepub fn new() -> EntropyCache
pub fn new() -> EntropyCache
Create new empty entropy cache with LRU eviction and metrics tracking (Task #135)
Sourcepub fn with_capacity(capacity: u64) -> EntropyCache
pub fn with_capacity(capacity: u64) -> EntropyCache
Create entropy cache with custom capacity (Issue #145: Global cache sizing)
Used by global entropy cache to support larger capacity (512-1024 entries) for improved hit ratio on multi-symbol workloads.
§Memory Usage
Approximate memory per entry: ~24 bytes (quick_cache overhead + u64 key + f64 value)
- 128 entries ≈ 3KB (default, per-processor)
- 512 entries ≈ 12KB (4x improvement)
- 1024 entries ≈ 24KB (8x improvement, global cache)
Sourcepub fn get(&self, prices: &[f64]) -> Option<f64>
pub fn get(&self, prices: &[f64]) -> Option<f64>
Get cached entropy result if available (O(1) operation) Tracks hit/miss metrics for cache effectiveness analysis (Task #135)
Sourcepub fn insert(&mut self, prices: &[f64], entropy: f64)
pub fn insert(&mut self, prices: &[f64], entropy: f64)
Cache entropy result (O(1) operation, quick_cache handles LRU eviction)
Sourcepub fn metrics(&self) -> (usize, usize, f64)
pub fn metrics(&self) -> (usize, usize, f64)
Get cache metrics: (hits, misses, hit_ratio) Returns hit ratio as percentage (0-100) for analysis (Task #135)
Sourcepub fn reset_metrics(&mut self)
pub fn reset_metrics(&mut self)
Reset metrics counters (useful for per-symbol analysis)
Trait Implementations§
Source§impl Debug for EntropyCache
impl Debug for EntropyCache
Source§impl Default for EntropyCache
impl Default for EntropyCache
Source§fn default() -> EntropyCache
fn default() -> EntropyCache
Auto Trait Implementations§
impl Freeze for EntropyCache
impl !RefUnwindSafe for EntropyCache
impl Send for EntropyCache
impl Sync for EntropyCache
impl Unpin for EntropyCache
impl UnsafeUnpin for EntropyCache
impl !UnwindSafe for EntropyCache
Blanket Implementations§
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