Skip to main content

EntropyCache

Struct EntropyCache 

Source
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

Source

pub fn new() -> EntropyCache

Create new empty entropy cache with LRU eviction and metrics tracking (Task #135)

Source

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)
Source

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)

Source

pub fn insert(&mut self, prices: &[f64], entropy: f64)

Cache entropy result (O(1) operation, quick_cache handles LRU eviction)

Source

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)

Source

pub fn reset_metrics(&mut self)

Reset metrics counters (useful for per-symbol analysis)

Trait Implementations§

Source§

impl Debug for EntropyCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for EntropyCache

Source§

fn default() -> EntropyCache

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.