Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a function Evaluator class with policy based caching capabilities #5253

Merged
merged 10 commits into from
Oct 31, 2024

Conversation

robertbindar
Copy link
Contributor

@robertbindar robertbindar commented Aug 23, 2024

#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 robertbindar force-pushed the rbin/ch51491/tile_offsets_cache branch 3 times, most recently from 95dab0c to b986936 Compare August 26, 2024 20:09
Copy link
Contributor

@eric-hughes-tiledb eric-hughes-tiledb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs more documentation in certain places. I didn't notice any defects overall. The tests, however, and not table-driven and thus not as extensive as this code deserves.

tiledb/common/evaluator/evaluator.h Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Outdated Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Outdated Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Outdated Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Outdated Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Outdated Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Outdated Show resolved Hide resolved
tiledb/common/evaluator/evaluator.h Outdated Show resolved Hide resolved
tiledb/common/evaluator/test/unit_evaluator.cc Outdated Show resolved Hide resolved
@bekadavis9 bekadavis9 force-pushed the rbin/ch51491/tile_offsets_cache branch from a823c9c to 8d48d60 Compare October 9, 2024 15:23
@bekadavis9 bekadavis9 force-pushed the rbin/ch51491/tile_offsets_cache branch from 8d48d60 to 94c7ac9 Compare October 15, 2024 19:05
@bekadavis9
Copy link
Contributor

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 bekadavis9 requested review from ihnorton and removed request for KiterLuc October 15, 2024 19:32
@bekadavis9 bekadavis9 merged commit 83e1419 into dev Oct 31, 2024
63 checks passed
@bekadavis9 bekadavis9 deleted the rbin/ch51491/tile_offsets_cache branch October 31, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants