lathe 0.0.0

scan resistant concurrent cache eviction manager
Documentation
  • Coverage
  • 60%
    3 out of 5 items documented0 out of 4 items with examples
  • Size
  • Source code size: 20.88 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.8 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • spacejam

cache-advisor

API:

impl CacheAdvisor {
  /// Create a new advisor.
  pub fn new(capacity: usize) -> CacheAdvisor { .. }

  /// Mark items that are accessed with a certain cost.
  /// Returns the items that should be evicted and their associated costs
  pub fn accessed(&mut self, id: u64, cost: usize) -> Vec<(u64, usize)> { .. }
}

Implementation details:

  • pushes accesses to a local queue
  • when the local queue reaches 8 items, pushes each access into one of 256 shards
  • each shard is protected by a mutex, but it never blocks to lock it, by using try_lock
  • if the mutex can't be acquired, the accesses are pushed into an access queue for the shard
  • if the mutex can be acquired, the acquiring thread applies accesses from the queue as well