Skip to content

Commit f6ebcb8

Browse files
authored
[chore](be) remove all LRU Cache default value (#59556) (#59751)
Issue Number: close #xxx pick #59556 Related PR: #xxx Problem Summary: None - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into --> ### What problem does this PR solve? Issue Number: close #xxx Related PR: #xxx Problem Summary: ### Release note None ### Check List (For Author) - Test <!-- At least one of them must be included. --> - [ ] Regression test - [ ] Unit Test - [ ] Manual test (add detailed scripts or steps below) - [ ] No need to test or manual test. Explain why: - [ ] This is a refactor/code format and no logic has been changed. - [ ] Previous test can cover this change. - [ ] No code files have been changed. - [ ] Other reason <!-- Add your reason? --> - Behavior changed: - [ ] No. - [ ] Yes. <!-- Explain the behavior change --> - Does this need documentation? - [ ] No. - [ ] Yes. <!-- Add document PR link here. eg: apache/doris-website#1214 --> ### Check List (For Reviewer who merge this PR) - [ ] Confirm the release note - [ ] Confirm test cases - [ ] Confirm document - [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
1 parent cb4d813 commit f6ebcb8

18 files changed

+67
-38
lines changed

be/src/cloud/cloud_tablet_mgr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ CloudTabletMgr::CloudTabletMgr(CloudStorageEngine& engine)
147147
_tablet_map(std::make_unique<TabletMap>()),
148148
_cache(std::make_unique<LRUCachePolicy>(
149149
CachePolicy::CacheType::CLOUD_TABLET_CACHE, config::tablet_cache_capacity,
150-
LRUCacheType::NUMBER, 0, config::tablet_cache_shards, false /*enable_prune*/)) {}
150+
LRUCacheType::NUMBER, /*sweep time*/ 0, config::tablet_cache_shards,
151+
/*element_count_capacity*/ 0, /*enable_prune*/ false,
152+
/*is_lru_k*/ false)) {}
151153

152154
CloudTabletMgr::~CloudTabletMgr() = default;
153155

be/src/cloud/cloud_txn_delete_bitmap_cache.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ namespace doris {
3434

3535
CloudTxnDeleteBitmapCache::CloudTxnDeleteBitmapCache(size_t size_in_bytes)
3636
: LRUCachePolicy(CachePolicy::CacheType::CLOUD_TXN_DELETE_BITMAP_CACHE, size_in_bytes,
37-
LRUCacheType::SIZE, 86400, 4),
37+
LRUCacheType::SIZE, /*stale_sweep_time_s*/ 86400, /*num_shards*/ 4,
38+
/*element_count_capacity*/ 0, /*enable_prune*/ true,
39+
/*is_lru_k*/ false),
3840
_stop_latch(1) {}
3941

4042
CloudTxnDeleteBitmapCache::~CloudTxnDeleteBitmapCache() {

be/src/olap/page_cache.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,24 +118,27 @@ class StoragePageCache {
118118
DataPageCache(size_t capacity, uint32_t num_shards)
119119
: LRUCachePolicy(CachePolicy::CacheType::DATA_PAGE_CACHE, capacity,
120120
LRUCacheType::SIZE, config::data_page_cache_stale_sweep_time_sec,
121-
num_shards, DEFAULT_LRU_CACHE_ELEMENT_COUNT_CAPACITY, true, true) {
122-
}
121+
num_shards, /*element_count_capacity*/ 0, /*enable_prune*/ true,
122+
/*is lru-k*/ true) {}
123123
};
124124

125125
class IndexPageCache : public LRUCachePolicy {
126126
public:
127127
IndexPageCache(size_t capacity, uint32_t num_shards)
128128
: LRUCachePolicy(CachePolicy::CacheType::INDEXPAGE_CACHE, capacity,
129129
LRUCacheType::SIZE, config::index_page_cache_stale_sweep_time_sec,
130-
num_shards) {}
130+
num_shards, /*element_count_capacity*/ 0, /*enable_prune*/ true,
131+
/*is lru-k*/ false) {}
131132
};
132133

133134
class PKIndexPageCache : public LRUCachePolicy {
134135
public:
135136
PKIndexPageCache(size_t capacity, uint32_t num_shards)
136137
: LRUCachePolicy(CachePolicy::CacheType::PK_INDEX_PAGE_CACHE, capacity,
137138
LRUCacheType::SIZE,
138-
config::pk_index_page_cache_stale_sweep_time_sec, num_shards) {}
139+
config::pk_index_page_cache_stale_sweep_time_sec, num_shards,
140+
/*element_count_capacity*/ 0, /*enable_prune*/ true,
141+
/*is lru-k*/ false) {}
139142
};
140143

141144
static constexpr uint32_t kDefaultNumShards = 16;

be/src/olap/rowset/segment_v2/inverted_index_cache.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,17 @@ class InvertedIndexSearcherCache {
106106
: LRUCachePolicy(CachePolicy::CacheType::INVERTEDINDEX_SEARCHER_CACHE, capacity,
107107
LRUCacheType::SIZE,
108108
config::inverted_index_cache_stale_sweep_time_sec, num_shards,
109-
element_count_capacity, true) {}
109+
element_count_capacity, /*enable_prune*/ true,
110+
/*is lru k*/ false) {}
110111
InvertedIndexSearcherCachePolicy(size_t capacity, uint32_t num_shards,
111112
uint32_t element_count_capacity,
112113
CacheValueTimeExtractor cache_value_time_extractor,
113114
bool cache_value_check_timestamp)
114-
: LRUCachePolicy(CachePolicy::CacheType::INVERTEDINDEX_SEARCHER_CACHE, capacity,
115-
LRUCacheType::SIZE,
116-
config::inverted_index_cache_stale_sweep_time_sec, num_shards,
117-
element_count_capacity, cache_value_time_extractor,
118-
cache_value_check_timestamp, true) {}
115+
: LRUCachePolicy(
116+
CachePolicy::CacheType::INVERTEDINDEX_SEARCHER_CACHE, capacity,
117+
LRUCacheType::SIZE, config::inverted_index_cache_stale_sweep_time_sec,
118+
num_shards, element_count_capacity, cache_value_time_extractor,
119+
cache_value_check_timestamp, /*enable_prune*/ true, /*is lru k*/ false) {}
119120
};
120121
// Insert a cache entry by key.
121122
// And the cache entry will be returned in handle.
@@ -229,7 +230,9 @@ class InvertedIndexQueryCache : public LRUCachePolicy {
229230
InvertedIndexQueryCache(size_t capacity, uint32_t num_shards)
230231
: LRUCachePolicy(CachePolicy::CacheType::INVERTEDINDEX_QUERY_CACHE, capacity,
231232
LRUCacheType::SIZE, config::inverted_index_cache_stale_sweep_time_sec,
232-
num_shards) {}
233+
num_shards,
234+
/*element_count_capacity*/ 0, /*enable_prune*/ true,
235+
/*is_lru_k*/ true) {}
233236

234237
bool lookup(const CacheKey& key, InvertedIndexQueryCacheHandle* handle);
235238

be/src/olap/schema_cache.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ class SchemaCache : public LRUCachePolicy {
8787

8888
SchemaCache(size_t capacity)
8989
: LRUCachePolicy(CachePolicy::CacheType::SCHEMA_CACHE, capacity, LRUCacheType::NUMBER,
90-
config::schema_cache_sweep_time_sec) {}
90+
config::schema_cache_sweep_time_sec, /*num shards*/ 32,
91+
/*element_count_capacity*/ 0, /*enable_prune*/ true,
92+
/*is lru-k*/ false) {}
9193

9294
private:
9395
static constexpr char SCHEMA_DELIMITER = '-';

be/src/olap/segment_loader.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ class SegmentCache : public LRUCachePolicy {
8383
};
8484

8585
SegmentCache(size_t memory_bytes_limit, size_t segment_num_limit)
86-
: LRUCachePolicy(
87-
CachePolicy::CacheType::SEGMENT_CACHE, memory_bytes_limit, LRUCacheType::SIZE,
88-
config::tablet_rowset_stale_sweep_time_sec, DEFAULT_LRU_CACHE_NUM_SHARDS * 2,
89-
cast_set<uint32_t>(segment_num_limit), config::enable_segment_cache_prune) {}
86+
: LRUCachePolicy(CachePolicy::CacheType::SEGMENT_CACHE, memory_bytes_limit,
87+
LRUCacheType::SIZE, config::tablet_rowset_stale_sweep_time_sec,
88+
/*num shards*/ 64,
89+
/*element count capacity */ cast_set<uint32_t>(segment_num_limit),
90+
config::enable_segment_cache_prune, /*is lru-k*/ true) {}
9091

9192
// Lookup the given segment in the cache.
9293
// If the segment is found, the cache entry will be written into handle.

be/src/olap/storage_engine.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,9 @@ class CreateTabletRRIdxCache : public LRUCachePolicy {
604604
CreateTabletRRIdxCache(size_t capacity)
605605
: LRUCachePolicy(CachePolicy::CacheType::CREATE_TABLET_RR_IDX_CACHE, capacity,
606606
LRUCacheType::NUMBER,
607-
/*stale_sweep_time_s*/ 30 * 60, 1) {}
607+
/*stale_sweep_time_s*/ 30 * 60, /*num shards*/ 1,
608+
/*element count capacity */ 0,
609+
/*enable prune*/ true, /*is lru-k*/ false) {}
608610
};
609611

610612
struct DirInfo {

be/src/olap/tablet_column_object_pool.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ class TabletColumnObjectPool : public LRUCachePolicy {
3434
public:
3535
TabletColumnObjectPool(size_t capacity)
3636
: LRUCachePolicy(CachePolicy::CacheType::TABLET_COLUMN_OBJECT_POOL, capacity,
37-
LRUCacheType::NUMBER, config::tablet_schema_cache_recycle_interval) {}
37+
LRUCacheType::NUMBER, config::tablet_schema_cache_recycle_interval,
38+
/*num_shards*/ 32,
39+
/*element_count_capacity*/ 0, /*enable_prune*/ true,
40+
/*is_lru_k*/ false) {}
3841

3942
static TabletColumnObjectPool* create_global_column_cache(size_t capacity) {
4043
auto* res = new TabletColumnObjectPool(capacity);

be/src/olap/tablet_meta.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,9 @@ static void decode_agg_cache_key(const std::string& key_str, int64_t& tablet_id,
12131213
DeleteBitmapAggCache::DeleteBitmapAggCache(size_t capacity)
12141214
: LRUCachePolicy(CachePolicy::CacheType::DELETE_BITMAP_AGG_CACHE, capacity,
12151215
LRUCacheType::SIZE, config::delete_bitmap_agg_cache_stale_sweep_time_sec,
1216-
256) {}
1216+
/*num_shards*/ 256,
1217+
/*element_count_capacity*/ 0, /*enable_prune*/ true,
1218+
/*is_lru_k*/ false) {}
12171219

12181220
DeleteBitmapAggCache* DeleteBitmapAggCache::instance() {
12191221
return ExecEnv::GetInstance()->delete_bitmap_agg_cache();

be/src/olap/tablet_schema_cache.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ class TabletSchemaCache : public LRUCachePolicy {
2929

3030
TabletSchemaCache(size_t capacity)
3131
: LRUCachePolicy(CachePolicy::CacheType::TABLET_SCHEMA_CACHE, capacity,
32-
LRUCacheType::NUMBER, config::tablet_schema_cache_recycle_interval) {}
32+
LRUCacheType::NUMBER, config::tablet_schema_cache_recycle_interval,
33+
/*num_shards*/ 32,
34+
/*element_count_capacity*/ 0, /*enable_prune*/ true,
35+
/*is_lru_k*/ false) {}
3336

3437
static TabletSchemaCache* create_global_schema_cache(size_t capacity) {
3538
auto* res = new TabletSchemaCache(capacity);

0 commit comments

Comments
 (0)