Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion be/src/cloud/cloud_tablet_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
4 changes: 3 additions & 1 deletion be/src/cloud/cloud_txn_delete_bitmap_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 7 additions & 4 deletions be/src/olap/page_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,27 @@ class StoragePageCache {
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 {
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 {
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;
Expand Down
4 changes: 3 additions & 1 deletion be/src/olap/rowset/segment_v2/condition_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ class ConditionCache : public LRUCachePolicy {

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);

Expand Down
17 changes: 10 additions & 7 deletions be/src/olap/rowset/segment_v2/inverted_index_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,17 @@ class InvertedIndexSearcherCache {
: 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.
Expand Down Expand Up @@ -229,7 +230,9 @@ class InvertedIndexQueryCache : public LRUCachePolicy {
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);

Expand Down
4 changes: 3 additions & 1 deletion be/src/olap/schema_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class SchemaCache : public LRUCachePolicy {

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 = '-';
Expand Down
9 changes: 5 additions & 4 deletions be/src/olap/segment_loader.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@ class SegmentCache : public LRUCachePolicy {
};

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.
Expand Down
4 changes: 3 additions & 1 deletion be/src/olap/storage_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ class CreateTabletRRIdxCache : public LRUCachePolicy {
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 {
Expand Down
5 changes: 4 additions & 1 deletion be/src/olap/tablet_column_object_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion be/src/olap/tablet_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
5 changes: 4 additions & 1 deletion be/src/olap/tablet_schema_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ class TabletSchemaCache : public LRUCachePolicy {

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);
Expand Down
6 changes: 4 additions & 2 deletions be/src/olap/txn_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ class TxnManager {
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:
Expand Down
4 changes: 3 additions & 1 deletion be/src/pipeline/query_cache/query_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ class QueryCache : public LRUCachePolicy {

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);

Expand Down
5 changes: 3 additions & 2 deletions be/src/runtime/load_channel_mgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@ class LoadChannelMgr {

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;
Expand Down
8 changes: 3 additions & 5 deletions be/src/runtime/memory/lru_cache_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -55,8 +54,7 @@ class LRUCachePolicy : public CachePolicy {
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)) {
Expand Down
3 changes: 2 additions & 1 deletion be/src/service/point_query_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions be/src/service/point_query_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,9 @@ class LookupConnectionCache : public LRUCachePolicy {
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;
Expand Down
3 changes: 2 additions & 1 deletion be/src/util/obj_lru_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions be/test/olap/lru_cache_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ class CacheTest : public testing::Test {
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
Expand Down
Loading