diff --git a/tools/db_bench_tool.cc b/tools/db_bench_tool.cc index bfddabe57..377460258 100644 --- a/tools/db_bench_tool.cc +++ b/tools/db_bench_tool.cc @@ -37,6 +37,7 @@ #include #include +#include "cache/fast_lru_cache.h" #include "db/db_impl/db_impl.h" #include "db/malloc_stats.h" #include "db/version_set.h" @@ -567,8 +568,7 @@ DEFINE_double(cache_high_pri_pool_ratio, 0.0, "If > 0.0, we also enable " "cache_index_and_filter_blocks_with_high_priority."); -DEFINE_bool(use_clock_cache, false, - "Replace default LRU block cache with clock cache."); +DEFINE_string(cache_type, "lru_cache", "Type of block cache."); DEFINE_bool(use_compressed_secondary_cache, false, "Use the CompressedSecondaryCache as the secondary cache."); @@ -2936,7 +2936,7 @@ class Benchmark { if (capacity <= 0) { return nullptr; } - if (FLAGS_use_clock_cache) { + if (FLAGS_cache_type == "clock_cache") { auto cache = NewClockCache(static_cast(capacity), FLAGS_cache_numshardbits); if (!cache) { @@ -2944,7 +2944,10 @@ class Benchmark { exit(1); } return cache; - } else { + } else if (FLAGS_cache_type == "fast_lru_cache") { + return NewFastLRUCache(static_cast(capacity), + FLAGS_cache_numshardbits); + } else if (FLAGS_cache_type == "lru_cache") { LRUCacheOptions opts( static_cast(capacity), FLAGS_cache_numshardbits, false /*strict_capacity_limit*/, FLAGS_cache_high_pri_pool_ratio, @@ -2993,6 +2996,9 @@ class Benchmark { } return NewLRUCache(opts); + } else { + fprintf(stderr, "Cache type not supported."); + exit(1); } }