From 7e1b4178246004c6dbdefe561eccb44d94c1787b Mon Sep 17 00:00:00 2001 From: Guido Tagliavini Ponce Date: Wed, 13 Jul 2022 17:43:39 -0700 Subject: [PATCH] Revert NewClockCache signature (#10358) Summary: This complements https://github.com/facebook/rocksdb/issues/10351. This PR reverts NewClockCache's signature to an older version, expected by the users of the old (buggy) ClockCache. Pull Request resolved: https://github.com/facebook/rocksdb/pull/10358 Test Plan: ``make -j24 check`` and re-run the pre-release tests. Reviewed By: siying Differential Revision: D37832601 Pulled By: guidotag fbshipit-source-id: 32a91d3da4119be187935003b7b897272ceb1950 --- cache/clock_cache.cc | 3 +-- db_stress_tool/db_stress_test_base.cc | 7 ++++--- include/rocksdb/cache.h | 7 ++++--- java/rocksjni/clock_cache.cc | 6 ++---- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cache/clock_cache.cc b/cache/clock_cache.cc index 86b4f0471..3f55acf6b 100644 --- a/cache/clock_cache.cc +++ b/cache/clock_cache.cc @@ -584,8 +584,7 @@ void ClockCache::DisownData() { } // namespace clock_cache std::shared_ptr NewClockCache( - size_t capacity, size_t /*estimated_value_size*/, int num_shard_bits, - bool strict_capacity_limit, + size_t capacity, int num_shard_bits, bool strict_capacity_limit, CacheMetadataChargePolicy metadata_charge_policy) { return NewLRUCache(capacity, num_shard_bits, strict_capacity_limit, 0.5, nullptr, kDefaultToAdaptiveMutex, metadata_charge_policy); diff --git a/db_stress_tool/db_stress_test_base.cc b/db_stress_tool/db_stress_test_base.cc index 63fae30e6..ee9baddfd 100644 --- a/db_stress_tool/db_stress_test_base.cc +++ b/db_stress_tool/db_stress_test_base.cc @@ -10,6 +10,7 @@ #include "util/compression.h" #ifdef GFLAGS +#include "cache/clock_cache.h" #include "cache/fast_lru_cache.h" #include "db_stress_tool/db_stress_common.h" #include "db_stress_tool/db_stress_compaction_filter.h" @@ -114,9 +115,9 @@ std::shared_ptr StressTest::NewCache(size_t capacity, } if (FLAGS_cache_type == "clock_cache") { - auto cache = NewClockCache(static_cast(capacity), FLAGS_block_size, - num_shard_bits, false /*strict_capacity_limit*/, - kDefaultCacheMetadataChargePolicy); + auto cache = ExperimentalNewClockCache( + static_cast(capacity), FLAGS_block_size, num_shard_bits, + false /*strict_capacity_limit*/, kDefaultCacheMetadataChargePolicy); if (!cache) { fprintf(stderr, "Clock cache not supported."); exit(1); diff --git a/include/rocksdb/cache.h b/include/rocksdb/cache.h index 49f5b80bc..ddc52613d 100644 --- a/include/rocksdb/cache.h +++ b/include/rocksdb/cache.h @@ -187,9 +187,10 @@ extern std::shared_ptr NewCompressedSecondaryCache( // Return nullptr if it is not supported. // `` extern std::shared_ptr NewClockCache( - size_t capacity, size_t estimated_value_size, int num_shard_bits, - bool strict_capacity_limit, - CacheMetadataChargePolicy metadata_charge_policy); + size_t capacity, int num_shard_bits = -1, + bool strict_capacity_limit = false, + CacheMetadataChargePolicy metadata_charge_policy = + kDefaultCacheMetadataChargePolicy); class Cache { public: diff --git a/java/rocksjni/clock_cache.cc b/java/rocksjni/clock_cache.cc index 911eed6b3..e04991aa9 100644 --- a/java/rocksjni/clock_cache.cc +++ b/java/rocksjni/clock_cache.cc @@ -23,10 +23,8 @@ jlong Java_org_rocksdb_ClockCache_newClockCache( jboolean jstrict_capacity_limit) { auto* sptr_clock_cache = new std::shared_ptr( ROCKSDB_NAMESPACE::NewClockCache( - static_cast(jcapacity), 1 /* estimated_value_size */, - static_cast(jnum_shard_bits), - static_cast(jstrict_capacity_limit), - rocksdb::CacheMetadataChargePolicy::kFullChargeCacheMetadata)); + static_cast(jcapacity), static_cast(jnum_shard_bits), + static_cast(jstrict_capacity_limit))); return GET_CPLUSPLUS_POINTER(sptr_clock_cache); }