Skip to content

Commit

Permalink
Replace per-shard chained hash tables with open-addressing scheme (#1…
Browse files Browse the repository at this point in the history
…0194)

Summary:
In FastLRUCache, we replace the current chained per-shard hash table by an open-addressing hash table. In particular, this allows us to preallocate all handles.

Because all handles are preallocated, this implementation doesn't support strict_capacity_limit = false (i.e., allowing insertions beyond the predefined capacity). This clashes with current assumptions of some tests, namely two tests in cache_test and the crash tests. We have disabled these for now.

Pull Request resolved: #10194

Test Plan: ``make -j24 check``

Reviewed By: pdillinger

Differential Revision: D37296770

Pulled By: guidotag

fbshipit-source-id: 232ff1b8260331d868ebf4e3e5d8ad709390b0ad
  • Loading branch information
Guido Tagliavini Ponce authored and facebook-github-bot committed Jun 21, 2022
1 parent deff48b commit 3afed74
Show file tree
Hide file tree
Showing 4 changed files with 475 additions and 219 deletions.
14 changes: 14 additions & 0 deletions cache/cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,10 @@ TEST_P(CacheTest, ReleaseWithoutErase) {
}

TEST_P(CacheTest, SetCapacity) {
if (GetParam() == kFast) {
ROCKSDB_GTEST_BYPASS("FastLRUCache doesn't support capacity adjustments.");
return;
}
// test1: increase capacity
// lets create a cache with capacity 5,
// then, insert 5 elements, then increase capacity
Expand Down Expand Up @@ -698,6 +702,12 @@ TEST_P(CacheTest, SetCapacity) {
}

TEST_P(LRUCacheTest, SetStrictCapacityLimit) {
if (GetParam() == kFast) {
ROCKSDB_GTEST_BYPASS(
"FastLRUCache doesn't support an unbounded number of inserts beyond "
"capacity.");
return;
}
// test1: set the flag to false. Insert more keys than capacity. See if they
// all go through.
std::shared_ptr<Cache> cache = NewCache(5, 0, false);
Expand Down Expand Up @@ -749,6 +759,10 @@ TEST_P(LRUCacheTest, SetStrictCapacityLimit) {
}

TEST_P(CacheTest, OverCapacity) {
if (GetParam() == kFast) {
ROCKSDB_GTEST_BYPASS("FastLRUCache doesn't support capacity adjustments.");
return;
}
size_t n = 10;

// a LRUCache with n entries and one shard only
Expand Down
Loading

0 comments on commit 3afed74

Please sign in to comment.