Skip to content

Commit

Permalink
Remove prototype FastLRUCache (facebook#10954)
Browse files Browse the repository at this point in the history
Summary:
This was just a stepping stone to what eventually became HyperClockCache, and is now just more code to maintain.

Pull Request resolved: facebook#10954

Test Plan: tests updated

Reviewed By: akankshamahajan15

Differential Revision: D41310123

Pulled By: pdillinger

fbshipit-source-id: 618ee148a1a0a29ee756ba8fe28359617b7cd67c
  • Loading branch information
pdillinger authored and facebook-github-bot committed Nov 16, 2022
1 parent b55e703 commit 32520df
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 1,254 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ set(SOURCES
cache/charged_cache.cc
cache/clock_cache.cc
cache/compressed_secondary_cache.cc
cache/fast_lru_cache.cc
cache/lru_cache.cc
cache/sharded_cache.cc
db/arena_wrapped_db_iter.cc
Expand Down
2 changes: 0 additions & 2 deletions TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ cpp_library_wrapper(name="rocksdb_lib", srcs=[
"cache/charged_cache.cc",
"cache/clock_cache.cc",
"cache/compressed_secondary_cache.cc",
"cache/fast_lru_cache.cc",
"cache/lru_cache.cc",
"cache/sharded_cache.cc",
"db/arena_wrapped_db_iter.cc",
Expand Down Expand Up @@ -356,7 +355,6 @@ cpp_library_wrapper(name="rocksdb_whole_archive_lib", srcs=[
"cache/charged_cache.cc",
"cache/clock_cache.cc",
"cache/compressed_secondary_cache.cc",
"cache/fast_lru_cache.cc",
"cache/lru_cache.cc",
"cache/sharded_cache.cc",
"db/arena_wrapped_db_iter.cc",
Expand Down
5 changes: 0 additions & 5 deletions cache/cache_bench_tool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <set>
#include <sstream>

#include "cache/fast_lru_cache.h"
#include "db/db_impl/db_impl.h"
#include "monitoring/histogram.h"
#include "port/port.h"
Expand Down Expand Up @@ -297,10 +296,6 @@ class CacheBench {
cache_ = HyperClockCacheOptions(FLAGS_cache_size, FLAGS_value_bytes,
FLAGS_num_shard_bits)
.MakeSharedCache();
} else if (FLAGS_cache_type == "fast_lru_cache") {
cache_ = NewFastLRUCache(
FLAGS_cache_size, FLAGS_value_bytes, FLAGS_num_shard_bits,
false /*strict_capacity_limit*/, kDefaultCacheMetadataChargePolicy);
} else if (FLAGS_cache_type == "lru_cache") {
LRUCacheOptions opts(FLAGS_cache_size, FLAGS_num_shard_bits,
false /* strict_capacity_limit */,
Expand Down
37 changes: 8 additions & 29 deletions cache/cache_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
#include <string>
#include <vector>

#include "cache/fast_lru_cache.h"
#include "cache/lru_cache.h"
#include "port/stack_trace.h"
#include "test_util/testharness.h"
#include "util/coding.h"
#include "util/string_util.h"

// FastLRUCache and HyperClockCache only support 16-byte keys, so some of
// the tests originally wrote for LRUCache do not work on the other caches.
// HyperClockCache only supports 16-byte keys, so some of the tests
// originally written for LRUCache do not work on the other caches.
// Those tests were adapted to use 16-byte keys. We kept the original ones.
// TODO: Remove the original tests if they ever become unused.

Expand Down Expand Up @@ -76,7 +75,6 @@ void EraseDeleter2(const Slice& /*key*/, void* value) {

const std::string kLRU = "lru";
const std::string kHyperClock = "hyper_clock";
const std::string kFast = "fast";

} // anonymous namespace

Expand All @@ -86,7 +84,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
static std::string type_;

static void Deleter(const Slice& key, void* v) {
if (type_ == kFast || type_ == kHyperClock) {
if (type_ == kHyperClock) {
current_->deleted_keys_.push_back(DecodeKey16Bytes(key));
} else {
current_->deleted_keys_.push_back(DecodeKey32Bits(key));
Expand Down Expand Up @@ -126,11 +124,6 @@ class CacheTest : public testing::TestWithParam<std::string> {
capacity, estimated_value_size_ /*estimated_value_size*/)
.MakeSharedCache();
}
if (type == kFast) {
return NewFastLRUCache(
capacity, estimated_value_size_, -1 /*num_shard_bits*/,
false /*strict_capacity_limit*/, kDefaultCacheMetadataChargePolicy);
}
return nullptr;
}

Expand All @@ -153,11 +146,6 @@ class CacheTest : public testing::TestWithParam<std::string> {
nullptr /*allocator*/, charge_policy)
.MakeSharedCache();
}
if (type == kFast) {
return NewFastLRUCache(capacity, 1 /*estimated_value_size*/,
num_shard_bits, strict_capacity_limit,
charge_policy);
}
return nullptr;
}

Expand All @@ -167,7 +155,7 @@ class CacheTest : public testing::TestWithParam<std::string> {
// LRUCache doesn't, so the encoding depends on the cache type.
std::string EncodeKey(int k) {
auto type = GetParam();
if (type == kFast || type == kHyperClock) {
if (type == kHyperClock) {
return EncodeKey16Bytes(k);
} else {
return EncodeKey32Bits(k);
Expand All @@ -176,7 +164,7 @@ class CacheTest : public testing::TestWithParam<std::string> {

int DecodeKey(const Slice& k) {
auto type = GetParam();
if (type == kFast || type == kHyperClock) {
if (type == kHyperClock) {
return DecodeKey16Bytes(k);
} else {
return DecodeKey32Bits(k);
Expand Down Expand Up @@ -733,7 +721,7 @@ TEST_P(CacheTest, ReleaseWithoutErase) {

TEST_P(CacheTest, SetCapacity) {
auto type = GetParam();
if (type == kFast || type == kHyperClock) {
if (type == kHyperClock) {
ROCKSDB_GTEST_BYPASS(
"FastLRUCache and HyperClockCache don't support arbitrary capacity "
"adjustments.");
Expand Down Expand Up @@ -787,14 +775,6 @@ TEST_P(CacheTest, SetCapacity) {
}

TEST_P(LRUCacheTest, SetStrictCapacityLimit) {
auto type = GetParam();
if (type == kFast) {
ROCKSDB_GTEST_BYPASS(
"FastLRUCache only supports a limited 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 @@ -1045,9 +1025,8 @@ TEST_P(CacheTest, GetChargeAndDeleter) {
}

INSTANTIATE_TEST_CASE_P(CacheTestInstance, CacheTest,
testing::Values(kLRU, kHyperClock, kFast));
INSTANTIATE_TEST_CASE_P(CacheTestInstance, LRUCacheTest,
testing::Values(kLRU, kFast));
testing::Values(kLRU, kHyperClock));
INSTANTIATE_TEST_CASE_P(CacheTestInstance, LRUCacheTest, testing::Values(kLRU));

} // namespace ROCKSDB_NAMESPACE

Expand Down
Loading

0 comments on commit 32520df

Please sign in to comment.