Add new API CacheReservationManager::GetDummyEntrySize() (#9072)
Summary: Note: it might conflict with another CRM related PR https://github.com/facebook/rocksdb/pull/9071 and so will merge after that's merged. Context: As `CacheReservationManager` being used by more memory users, it is convenient to retrieve the dummy entry size for `CacheReservationManager` instead of hard-coding `256 * 1024` in writing tests. Plus it allows more flexibility to change our implementation on dummy entry size. A follow-up PR is needed to replace those hard-coded dummy entry size value in `db_test2.cc`, `db_write_buffer_manager_test.cc`, `write_buffer_manager_test.cc`, `table_test.cc` and the ones introduced in https://github.com/facebook/rocksdb/pull/9072#issue-1034326069. - Exposed the private static constexpr `kDummyEntrySize` through public static `CacheReservationManager::GetDummyEntrySize()` Pull Request resolved: https://github.com/facebook/rocksdb/pull/9072 Test Plan: - Passing new tests - Passing existing tests Reviewed By: ajkr Differential Revision: D32043684 Pulled By: hx235 fbshipit-source-id: ddefc6921c052adab6a2cda2394eb26da3076a50
This commit is contained in:
parent
a2b9be42b6
commit
560fe70233
2
cache/cache_reservation_manager.h
vendored
2
cache/cache_reservation_manager.h
vendored
@ -75,6 +75,8 @@ class CacheReservationManager {
|
|||||||
Status UpdateCacheReservation(std::size_t new_memory_used);
|
Status UpdateCacheReservation(std::size_t new_memory_used);
|
||||||
std::size_t GetTotalReservedCacheSize();
|
std::size_t GetTotalReservedCacheSize();
|
||||||
|
|
||||||
|
static constexpr std::size_t GetDummyEntrySize() { return kSizeDummyEntry; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr std::size_t kSizeDummyEntry = 256 * 1024;
|
static constexpr std::size_t kSizeDummyEntry = 256 * 1024;
|
||||||
// The key will be longer than keys for blocks in SST files so they won't
|
// The key will be longer than keys for blocks in SST files so they won't
|
||||||
|
12
cache/cache_reservation_manager_test.cc
vendored
12
cache/cache_reservation_manager_test.cc
vendored
@ -25,7 +25,8 @@ class CacheReservationManagerTest : public ::testing::Test {
|
|||||||
static constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
static constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
||||||
static constexpr int kNumShardBits = 0; // 2^0 shard
|
static constexpr int kNumShardBits = 0; // 2^0 shard
|
||||||
|
|
||||||
static constexpr std::size_t kSizeDummyEntry = 256 * 1024;
|
static constexpr std::size_t kSizeDummyEntry =
|
||||||
|
CacheReservationManager::GetDummyEntrySize();
|
||||||
static const std::size_t kCacheKeyPrefixSize =
|
static const std::size_t kCacheKeyPrefixSize =
|
||||||
BlockBasedTable::kMaxCacheKeyPrefixSize + kMaxVarint64Length;
|
BlockBasedTable::kMaxCacheKeyPrefixSize + kMaxVarint64Length;
|
||||||
static constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
static constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
||||||
@ -143,7 +144,8 @@ TEST(CacheReservationManagerIncreaseReservcationOnFullCacheTest,
|
|||||||
IncreaseCacheReservationOnFullCache) {
|
IncreaseCacheReservationOnFullCache) {
|
||||||
constexpr std::size_t kOneMegabyte = 1024 * 1024;
|
constexpr std::size_t kOneMegabyte = 1024 * 1024;
|
||||||
constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
||||||
constexpr std::size_t kSizeDummyEntry = 256 * 1024;
|
constexpr std::size_t kSizeDummyEntry =
|
||||||
|
CacheReservationManager::GetDummyEntrySize();
|
||||||
constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
||||||
|
|
||||||
LRUCacheOptions lo;
|
LRUCacheOptions lo;
|
||||||
@ -307,7 +309,8 @@ TEST_F(CacheReservationManagerTest,
|
|||||||
TEST(CacheReservationManagerWithDelayedDecreaseTest,
|
TEST(CacheReservationManagerWithDelayedDecreaseTest,
|
||||||
DecreaseCacheReservationWithDelayedDecrease) {
|
DecreaseCacheReservationWithDelayedDecrease) {
|
||||||
constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
||||||
constexpr std::size_t kSizeDummyEntry = 256 * 1024;
|
constexpr std::size_t kSizeDummyEntry =
|
||||||
|
CacheReservationManager::GetDummyEntrySize();
|
||||||
constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
||||||
|
|
||||||
LRUCacheOptions lo;
|
LRUCacheOptions lo;
|
||||||
@ -379,7 +382,8 @@ TEST(CacheReservationManagerWithDelayedDecreaseTest,
|
|||||||
TEST(CacheReservationManagerDestructorTest,
|
TEST(CacheReservationManagerDestructorTest,
|
||||||
ReleaseRemainingDummyEntriesOnDestruction) {
|
ReleaseRemainingDummyEntriesOnDestruction) {
|
||||||
constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
constexpr std::size_t kOneGigabyte = 1024 * 1024 * 1024;
|
||||||
constexpr std::size_t kSizeDummyEntry = 256 * 1024;
|
constexpr std::size_t kSizeDummyEntry =
|
||||||
|
CacheReservationManager::GetDummyEntrySize();
|
||||||
constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
constexpr std::size_t kMetaDataChargeOverhead = 10000;
|
||||||
|
|
||||||
LRUCacheOptions lo;
|
LRUCacheOptions lo;
|
||||||
|
Loading…
Reference in New Issue
Block a user