TileDB icon indicating copy to clipboard operation
TileDB copied to clipboard

Add a function Evaluator class with policy based caching capabilities

Open robertbindar opened this issue 1 year ago • 1 comments

https://github.com/TileDB-Inc/TileDB/pull/5215 for context and previous reviews. This work evolved into something a bit more generic than the tile offsets transparent cache we originally intended to write. This PR adds:

  • Evaluator class
Evaluator<Policy<Key, Value>, decltype(cb)> eval(cb);
val = eval(key);

// where
Value cb(const Key& key);
  • ImmediateEvaluation policy Configures the evaluator to execute cb(key) for any invocation of eval(key).
Evaluator<ImmediateEvaluation<Key, Value>, Callback> eval(cb);
eval(key); // equivalent with cb(key)
eval(key); // equivalent with cb(key)
  • MaxEntriesCache policy Configures the evaluator to execute cb(key) and cache the results in a LRU cache that cannot hold more than N values. Caching value N+1 triggers cache eviction.
Evaluator<MaxEntriesCache<Key, Value, N>, Callback> eval(cb);
  • MemoryBudgetedCache policy Configures the evaluator to execute cb(key) and cache the results in a LRU cache with a capacity of M bytes where M is passed during the evaluator construction.
Evaluator<MemoryBudgetedCache<Key, Value>, Callback> eval(cb, SizeFn, memory_budget);
// where `SizeFn` is a user provided function that returns the size of its argument in bytes.

[sc-51496]


TYPE: FEATURE DESC: Add a function Evaluator class with policy based caching capabilities

robertbindar avatar Aug 23 '24 12:08 robertbindar

Note: Table-driven tests increase coverage, but each case is run in parallel. The nature of this cache testing is that many of the tests rely on serial function calls. A rewrite may be worthwhile in the future, but is overly complicated for the scope of this PR.

bekadavis9 avatar Oct 15 '24 19:10 bekadavis9