This is an automated email from the ASF dual-hosted git repository.
yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new b06c726823f [chore](be) remove all LRU Cache default value (#59556)
b06c726823f is described below
commit b06c726823fa9326bd77ac879fee51f818568229
Author: yiguolei <[email protected]>
AuthorDate: Mon Jan 12 11:01:19 2026 +0800
[chore](be) remove all LRU Cache default value (#59556)
### 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:
https://github.com/apache/doris-website/pull/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 -->
---
be/src/cloud/cloud_tablet_mgr.cpp | 4 +++-
be/src/cloud/cloud_txn_delete_bitmap_cache.cpp | 4 +++-
be/src/olap/page_cache.h | 11 +++++++----
be/src/olap/rowset/segment_v2/condition_cache.h | 4 +++-
be/src/olap/rowset/segment_v2/inverted_index_cache.h | 17 ++++++++++-------
be/src/olap/schema_cache.h | 4 +++-
be/src/olap/segment_loader.h | 9 +++++----
be/src/olap/storage_engine.h | 4 +++-
be/src/olap/tablet_column_object_pool.h | 5 ++++-
be/src/olap/tablet_meta.cpp | 4 +++-
be/src/olap/tablet_schema_cache.h | 5 ++++-
be/src/olap/txn_manager.h | 6 ++++--
be/src/pipeline/query_cache/query_cache.h | 4 +++-
be/src/runtime/load_channel_mgr.h | 5 +++--
be/src/runtime/memory/lru_cache_policy.h | 8 +++-----
be/src/service/point_query_executor.cpp | 3 ++-
be/src/service/point_query_executor.h | 5 +++--
be/src/util/obj_lru_cache.cpp | 3 ++-
be/test/olap/lru_cache_test.cpp | 4 ++--
19 files changed, 70 insertions(+), 39 deletions(-)
diff --git a/be/src/cloud/cloud_tablet_mgr.cpp
b/be/src/cloud/cloud_tablet_mgr.cpp
index 94383ac3d0d..854bb29315f 100644
--- a/be/src/cloud/cloud_tablet_mgr.cpp
+++ b/be/src/cloud/cloud_tablet_mgr.cpp
@@ -148,7 +148,9 @@ CloudTabletMgr::CloudTabletMgr(CloudStorageEngine& engine)
_tablet_map(std::make_unique<TabletMap>()),
_cache(std::make_unique<LRUCachePolicy>(
CachePolicy::CacheType::CLOUD_TABLET_CACHE,
config::tablet_cache_capacity,
- LRUCacheType::NUMBER, 0, config::tablet_cache_shards, false
/*enable_prune*/)) {}
+ LRUCacheType::NUMBER, /*sweep time*/ 0,
config::tablet_cache_shards,
+ /*element_count_capacity*/ 0, /*enable_prune*/ false,
+ /*is_lru_k*/ false)) {}
CloudTabletMgr::~CloudTabletMgr() = default;
diff --git a/be/src/cloud/cloud_txn_delete_bitmap_cache.cpp
b/be/src/cloud/cloud_txn_delete_bitmap_cache.cpp
index a0f3b201429..e1d51200415 100644
--- a/be/src/cloud/cloud_txn_delete_bitmap_cache.cpp
+++ b/be/src/cloud/cloud_txn_delete_bitmap_cache.cpp
@@ -34,7 +34,9 @@ namespace doris {
CloudTxnDeleteBitmapCache::CloudTxnDeleteBitmapCache(size_t size_in_bytes)
:
LRUCachePolicy(CachePolicy::CacheType::CLOUD_TXN_DELETE_BITMAP_CACHE,
size_in_bytes,
- LRUCacheType::SIZE, 86400, 4),
+ LRUCacheType::SIZE, /*stale_sweep_time_s*/ 86400,
/*num_shards*/ 4,
+ /*element_count_capacity*/ 0, /*enable_prune*/ true,
+ /*is_lru_k*/ false),
_stop_latch(1) {}
CloudTxnDeleteBitmapCache::~CloudTxnDeleteBitmapCache() {
diff --git a/be/src/olap/page_cache.h b/be/src/olap/page_cache.h
index f19dff67c32..308eef8b524 100644
--- a/be/src/olap/page_cache.h
+++ b/be/src/olap/page_cache.h
@@ -118,8 +118,8 @@ public:
DataPageCache(size_t capacity, uint32_t num_shards)
: LRUCachePolicy(CachePolicy::CacheType::DATA_PAGE_CACHE,
capacity,
LRUCacheType::SIZE,
config::data_page_cache_stale_sweep_time_sec,
- num_shards,
DEFAULT_LRU_CACHE_ELEMENT_COUNT_CAPACITY, true, true) {
- }
+ num_shards, /*element_count_capacity*/ 0,
/*enable_prune*/ true,
+ /*is lru-k*/ true) {}
};
class IndexPageCache : public LRUCachePolicy {
@@ -127,7 +127,8 @@ public:
IndexPageCache(size_t capacity, uint32_t num_shards)
: LRUCachePolicy(CachePolicy::CacheType::INDEXPAGE_CACHE,
capacity,
LRUCacheType::SIZE,
config::index_page_cache_stale_sweep_time_sec,
- num_shards) {}
+ num_shards, /*element_count_capacity*/ 0,
/*enable_prune*/ true,
+ /*is lru-k*/ false) {}
};
class PKIndexPageCache : public LRUCachePolicy {
@@ -135,7 +136,9 @@ public:
PKIndexPageCache(size_t capacity, uint32_t num_shards)
: LRUCachePolicy(CachePolicy::CacheType::PK_INDEX_PAGE_CACHE,
capacity,
LRUCacheType::SIZE,
-
config::pk_index_page_cache_stale_sweep_time_sec, num_shards) {}
+
config::pk_index_page_cache_stale_sweep_time_sec, num_shards,
+ /*element_count_capacity*/ 0,
/*enable_prune*/ true,
+ /*is lru-k*/ false) {}
};
static constexpr uint32_t kDefaultNumShards = 16;
diff --git a/be/src/olap/rowset/segment_v2/condition_cache.h
b/be/src/olap/rowset/segment_v2/condition_cache.h
index 68a7dc10a08..cc66b20417c 100644
--- a/be/src/olap/rowset/segment_v2/condition_cache.h
+++ b/be/src/olap/rowset/segment_v2/condition_cache.h
@@ -83,7 +83,9 @@ public:
ConditionCache(size_t capacity, uint32_t num_shards)
: LRUCachePolicy(CachePolicy::CacheType::CONDITION_CACHE,
capacity, LRUCacheType::SIZE,
-
config::inverted_index_cache_stale_sweep_time_sec, num_shards) {}
+
config::inverted_index_cache_stale_sweep_time_sec, num_shards,
+ /*element_count_capacity*/ 0, /*enable_prune*/
true,
+ /*is_lru_k*/ true) {}
bool lookup(const CacheKey& key, ConditionCacheHandle* handle);
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_cache.h
b/be/src/olap/rowset/segment_v2/inverted_index_cache.h
index b80f2c01027..64392f6bb51 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_cache.h
+++ b/be/src/olap/rowset/segment_v2/inverted_index_cache.h
@@ -106,16 +106,17 @@ private:
:
LRUCachePolicy(CachePolicy::CacheType::INVERTEDINDEX_SEARCHER_CACHE, capacity,
LRUCacheType::SIZE,
config::inverted_index_cache_stale_sweep_time_sec, num_shards,
- element_count_capacity, true) {}
+ element_count_capacity, /*enable_prune*/ true,
+ /*is lru k*/ false) {}
InvertedIndexSearcherCachePolicy(size_t capacity, uint32_t num_shards,
uint32_t element_count_capacity,
CacheValueTimeExtractor
cache_value_time_extractor,
bool cache_value_check_timestamp)
- :
LRUCachePolicy(CachePolicy::CacheType::INVERTEDINDEX_SEARCHER_CACHE, capacity,
- LRUCacheType::SIZE,
-
config::inverted_index_cache_stale_sweep_time_sec, num_shards,
- element_count_capacity,
cache_value_time_extractor,
- cache_value_check_timestamp, true) {}
+ : LRUCachePolicy(
+
CachePolicy::CacheType::INVERTEDINDEX_SEARCHER_CACHE, capacity,
+ LRUCacheType::SIZE,
config::inverted_index_cache_stale_sweep_time_sec,
+ num_shards, element_count_capacity,
cache_value_time_extractor,
+ cache_value_check_timestamp, /*enable_prune*/ true,
/*is lru k*/ false) {}
};
// Insert a cache entry by key.
// And the cache entry will be returned in handle.
@@ -229,7 +230,9 @@ public:
InvertedIndexQueryCache(size_t capacity, uint32_t num_shards)
:
LRUCachePolicy(CachePolicy::CacheType::INVERTEDINDEX_QUERY_CACHE, capacity,
LRUCacheType::SIZE,
config::inverted_index_cache_stale_sweep_time_sec,
- num_shards) {}
+ num_shards,
+ /*element_count_capacity*/ 0, /*enable_prune*/
true,
+ /*is_lru_k*/ true) {}
bool lookup(const CacheKey& key, InvertedIndexQueryCacheHandle* handle);
diff --git a/be/src/olap/schema_cache.h b/be/src/olap/schema_cache.h
index 68cd809ed22..3def66a90f5 100644
--- a/be/src/olap/schema_cache.h
+++ b/be/src/olap/schema_cache.h
@@ -87,7 +87,9 @@ public:
SchemaCache(size_t capacity)
: LRUCachePolicy(CachePolicy::CacheType::SCHEMA_CACHE, capacity,
LRUCacheType::NUMBER,
- config::schema_cache_sweep_time_sec) {}
+ config::schema_cache_sweep_time_sec, /*num
shards*/ 32,
+ /*element_count_capacity*/ 0, /*enable_prune*/
true,
+ /*is lru-k*/ false) {}
private:
static constexpr char SCHEMA_DELIMITER = '-';
diff --git a/be/src/olap/segment_loader.h b/be/src/olap/segment_loader.h
index 48b3cb17355..42b0201a1ff 100644
--- a/be/src/olap/segment_loader.h
+++ b/be/src/olap/segment_loader.h
@@ -83,10 +83,11 @@ public:
};
SegmentCache(size_t memory_bytes_limit, size_t segment_num_limit)
- : LRUCachePolicy(
- CachePolicy::CacheType::SEGMENT_CACHE,
memory_bytes_limit, LRUCacheType::SIZE,
- config::tablet_rowset_stale_sweep_time_sec,
DEFAULT_LRU_CACHE_NUM_SHARDS * 2,
- cast_set<uint32_t>(segment_num_limit),
config::enable_segment_cache_prune) {}
+ : LRUCachePolicy(CachePolicy::CacheType::SEGMENT_CACHE,
memory_bytes_limit,
+ LRUCacheType::SIZE,
config::tablet_rowset_stale_sweep_time_sec,
+ /*num shards*/ 64,
+ /*element count capacity */
cast_set<uint32_t>(segment_num_limit),
+ config::enable_segment_cache_prune, /*is lru-k*/
true) {}
// Lookup the given segment in the cache.
// If the segment is found, the cache entry will be written into handle.
diff --git a/be/src/olap/storage_engine.h b/be/src/olap/storage_engine.h
index 0977d66a802..ecc6504308b 100644
--- a/be/src/olap/storage_engine.h
+++ b/be/src/olap/storage_engine.h
@@ -624,7 +624,9 @@ public:
CreateTabletRRIdxCache(size_t capacity)
:
LRUCachePolicy(CachePolicy::CacheType::CREATE_TABLET_RR_IDX_CACHE, capacity,
LRUCacheType::NUMBER,
- /*stale_sweep_time_s*/ 30 * 60, 1) {}
+ /*stale_sweep_time_s*/ 30 * 60, /*num shards*/ 1,
+ /*element count capacity */ 0,
+ /*enable prune*/ true, /*is lru-k*/ false) {}
};
struct DirInfo {
diff --git a/be/src/olap/tablet_column_object_pool.h
b/be/src/olap/tablet_column_object_pool.h
index 998ba7a9aa4..8383b805c1f 100644
--- a/be/src/olap/tablet_column_object_pool.h
+++ b/be/src/olap/tablet_column_object_pool.h
@@ -34,7 +34,10 @@ class TabletColumnObjectPool : public LRUCachePolicy {
public:
TabletColumnObjectPool(size_t capacity)
:
LRUCachePolicy(CachePolicy::CacheType::TABLET_COLUMN_OBJECT_POOL, capacity,
- LRUCacheType::NUMBER,
config::tablet_schema_cache_recycle_interval) {}
+ LRUCacheType::NUMBER,
config::tablet_schema_cache_recycle_interval,
+ /*num_shards*/ 32,
+ /*element_count_capacity*/ 0, /*enable_prune*/
true,
+ /*is_lru_k*/ false) {}
static TabletColumnObjectPool* create_global_column_cache(size_t capacity)
{
auto* res = new TabletColumnObjectPool(capacity);
diff --git a/be/src/olap/tablet_meta.cpp b/be/src/olap/tablet_meta.cpp
index d60d71b891e..61c6c7508d3 100644
--- a/be/src/olap/tablet_meta.cpp
+++ b/be/src/olap/tablet_meta.cpp
@@ -1223,7 +1223,9 @@ static void decode_agg_cache_key(const std::string&
key_str, int64_t& tablet_id,
DeleteBitmapAggCache::DeleteBitmapAggCache(size_t capacity)
: LRUCachePolicy(CachePolicy::CacheType::DELETE_BITMAP_AGG_CACHE,
capacity,
LRUCacheType::SIZE,
config::delete_bitmap_agg_cache_stale_sweep_time_sec,
- 256) {}
+ /*num_shards*/ 256,
+ /*element_count_capacity*/ 0, /*enable_prune*/ true,
+ /*is_lru_k*/ false) {}
DeleteBitmapAggCache* DeleteBitmapAggCache::instance() {
return ExecEnv::GetInstance()->delete_bitmap_agg_cache();
diff --git a/be/src/olap/tablet_schema_cache.h
b/be/src/olap/tablet_schema_cache.h
index e18892a3ca5..808b7b4a9cf 100644
--- a/be/src/olap/tablet_schema_cache.h
+++ b/be/src/olap/tablet_schema_cache.h
@@ -29,7 +29,10 @@ public:
TabletSchemaCache(size_t capacity)
: LRUCachePolicy(CachePolicy::CacheType::TABLET_SCHEMA_CACHE,
capacity,
- LRUCacheType::NUMBER,
config::tablet_schema_cache_recycle_interval) {}
+ LRUCacheType::NUMBER,
config::tablet_schema_cache_recycle_interval,
+ /*num_shards*/ 32,
+ /*element_count_capacity*/ 0, /*enable_prune*/
true,
+ /*is_lru_k*/ false) {}
static TabletSchemaCache* create_global_schema_cache(size_t capacity) {
auto* res = new TabletSchemaCache(capacity);
diff --git a/be/src/olap/txn_manager.h b/be/src/olap/txn_manager.h
index 7de2d39db1a..52663fed4d5 100644
--- a/be/src/olap/txn_manager.h
+++ b/be/src/olap/txn_manager.h
@@ -302,8 +302,10 @@ private:
public:
TabletVersionCache(size_t capacity)
: LRUCachePolicy(CachePolicy::CacheType::TABLET_VERSION_CACHE,
capacity,
- LRUCacheType::NUMBER, -1,
DEFAULT_LRU_CACHE_NUM_SHARDS,
- DEFAULT_LRU_CACHE_ELEMENT_COUNT_CAPACITY,
false) {}
+ LRUCacheType::NUMBER, /*sweeptime*/ -1,
+ /*num_shards*/ 32,
+ /*element_count_capacity*/ 0,
/*enable_prune*/ false,
+ /*is_lru_k*/ false) {}
};
private:
diff --git a/be/src/pipeline/query_cache/query_cache.h
b/be/src/pipeline/query_cache/query_cache.h
index 827c516ad75..4ac06bd5116 100644
--- a/be/src/pipeline/query_cache/query_cache.h
+++ b/be/src/pipeline/query_cache/query_cache.h
@@ -142,7 +142,9 @@ public:
QueryCache(size_t capacity, uint32_t num_shards)
: LRUCachePolicy(CachePolicy::CacheType::QUERY_CACHE, capacity,
LRUCacheType::SIZE,
- 3600 * 24, num_shards) {}
+ 3600 * 24, /*num_shards*/ num_shards,
+ /*element_count_capacity*/ 0, /*enable_prune*/
true,
+ /*is_lru_k*/ true) {}
bool lookup(const CacheKey& key, int64_t version, QueryCacheHandle*
handle);
diff --git a/be/src/runtime/load_channel_mgr.h
b/be/src/runtime/load_channel_mgr.h
index 989f2ac0530..3c2b7d01571 100644
--- a/be/src/runtime/load_channel_mgr.h
+++ b/be/src/runtime/load_channel_mgr.h
@@ -91,8 +91,9 @@ private:
LoadStateChannelCache(size_t capacity)
:
LRUCachePolicy(CachePolicy::CacheType::LOAD_STATE_CHANNEL_CACHE, capacity,
- LRUCacheType::NUMBER, -1,
DEFAULT_LRU_CACHE_NUM_SHARDS,
- DEFAULT_LRU_CACHE_ELEMENT_COUNT_CAPACITY,
false) {}
+ LRUCacheType::NUMBER, /*sweep time*/ -1,
/*num shards*/ 32,
+ /*element capacity*/ 0, /*enable prune */
false,
+ /*is lru k*/ false) {}
};
using CacheValue = LoadStateChannelCache::CacheValue;
diff --git a/be/src/runtime/memory/lru_cache_policy.h
b/be/src/runtime/memory/lru_cache_policy.h
index ddc3f186e7c..dd2ebcabbb0 100644
--- a/be/src/runtime/memory/lru_cache_policy.h
+++ b/be/src/runtime/memory/lru_cache_policy.h
@@ -35,9 +35,8 @@ namespace doris {
class LRUCachePolicy : public CachePolicy {
public:
LRUCachePolicy(CacheType type, size_t capacity, LRUCacheType
lru_cache_type,
- uint32_t stale_sweep_time_s, uint32_t num_shards =
DEFAULT_LRU_CACHE_NUM_SHARDS,
- uint32_t element_count_capacity =
DEFAULT_LRU_CACHE_ELEMENT_COUNT_CAPACITY,
- bool enable_prune = true, bool is_lru_k =
DEFAULT_LRU_CACHE_IS_LRU_K)
+ uint32_t stale_sweep_time_s, uint32_t num_shards,
+ uint32_t element_count_capacity, bool enable_prune, bool
is_lru_k)
: CachePolicy(type, capacity, stale_sweep_time_s, enable_prune),
_lru_cache_type(lru_cache_type) {
if (check_capacity(capacity, num_shards)) {
@@ -55,8 +54,7 @@ public:
uint32_t stale_sweep_time_s, uint32_t num_shards,
uint32_t element_count_capacity,
CacheValueTimeExtractor cache_value_time_extractor,
- bool cache_value_check_timestamp, bool enable_prune = true,
- bool is_lru_k = DEFAULT_LRU_CACHE_IS_LRU_K)
+ bool cache_value_check_timestamp, bool enable_prune, bool
is_lru_k)
: CachePolicy(type, capacity, stale_sweep_time_s, enable_prune),
_lru_cache_type(lru_cache_type) {
if (check_capacity(capacity, num_shards)) {
diff --git a/be/src/service/point_query_executor.cpp
b/be/src/service/point_query_executor.cpp
index 5c5ca44c3e6..a8f8eadd1f2 100644
--- a/be/src/service/point_query_executor.cpp
+++ b/be/src/service/point_query_executor.cpp
@@ -216,7 +216,8 @@ LookupConnectionCache*
LookupConnectionCache::create_global_instance(size_t capa
RowCache::RowCache(int64_t capacity, int num_shards)
: LRUCachePolicy(CachePolicy::CacheType::POINT_QUERY_ROW_CACHE,
capacity,
LRUCacheType::SIZE,
config::point_query_row_cache_stale_sweep_time_sec,
- num_shards) {}
+ num_shards, /*element count capacity */ 0,
+ /*enable prune*/ true, /*is lru-k*/ true) {}
// Create global instance of this class
RowCache* RowCache::create_global_cache(int64_t capacity, uint32_t num_shards)
{
diff --git a/be/src/service/point_query_executor.h
b/be/src/service/point_query_executor.h
index ffddfe86db5..1b76c3da6e4 100644
--- a/be/src/service/point_query_executor.h
+++ b/be/src/service/point_query_executor.h
@@ -232,8 +232,9 @@ private:
friend class PointQueryExecutor;
LookupConnectionCache(size_t capacity)
: LRUCachePolicy(CachePolicy::CacheType::LOOKUP_CONNECTION_CACHE,
capacity,
- LRUCacheType::NUMBER,
- config::tablet_lookup_cache_stale_sweep_time_sec)
{}
+ LRUCacheType::NUMBER,
config::tablet_lookup_cache_stale_sweep_time_sec,
+ /*num shards*/ 32, /*element count capacity */ 0,
+ /*enable prune*/ true, /*is lru-k*/ true) {}
static std::string encode_key(__int128_t cache_id) {
fmt::memory_buffer buffer;
diff --git a/be/src/util/obj_lru_cache.cpp b/be/src/util/obj_lru_cache.cpp
index fb03f1907d3..be7e654b8b2 100644
--- a/be/src/util/obj_lru_cache.cpp
+++ b/be/src/util/obj_lru_cache.cpp
@@ -22,7 +22,8 @@ namespace doris {
ObjLRUCache::ObjLRUCache(int64_t capacity, uint32_t num_shards)
: LRUCachePolicy(CachePolicy::CacheType::COMMON_OBJ_LRU_CACHE,
capacity,
LRUCacheType::NUMBER,
config::common_obj_lru_cache_stale_sweep_time_sec,
- num_shards),
+ /*num shards*/ 32, /*element count capacity */ 0,
+ /*enable prune*/ true, /*is lru-k*/ true),
_enabled(capacity > 0) {}
bool ObjLRUCache::lookup(const ObjKey& key, CacheHandle* handle) {
diff --git a/be/test/olap/lru_cache_test.cpp b/be/test/olap/lru_cache_test.cpp
index 64fe925f15f..ee8a64fc927 100644
--- a/be/test/olap/lru_cache_test.cpp
+++ b/be/test/olap/lru_cache_test.cpp
@@ -93,14 +93,14 @@ public:
public:
CacheTestSizePolicy(size_t capacity)
: LRUCachePolicy(CachePolicy::CacheType::FOR_UT_CACHE_SIZE,
capacity,
- LRUCacheType::SIZE, -1) {}
+ LRUCacheType::SIZE, -1, 32, 0, true, false) {}
};
class CacheTestNumberPolicy : public LRUCachePolicy {
public:
CacheTestNumberPolicy(size_t capacity, uint32_t num_shards)
: LRUCachePolicy(CachePolicy::CacheType::FOR_UT_CACHE_NUMBER,
capacity,
- LRUCacheType::NUMBER, -1, num_shards) {}
+ LRUCacheType::NUMBER, -1, num_shards, 0,
true, false) {}
};
// there is 16 shards in ShardedLRUCache
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]