xinyiZzz commented on code in PR #28940:
URL: https://github.com/apache/doris/pull/28940#discussion_r1435956783
##########
be/src/olap/page_cache.cpp:
##########
@@ -36,19 +36,21 @@ StoragePageCache*
StoragePageCache::create_global_cache(size_t capacity,
StoragePageCache::StoragePageCache(size_t capacity, int32_t
index_cache_percentage,
int64_t pk_index_cache_capacity, uint32_t
num_shards)
: _index_cache_percentage(index_cache_percentage) {
- if (index_cache_percentage == 0) {
- _data_page_cache = std::make_unique<DataPageCache>(capacity,
num_shards);
- } else if (index_cache_percentage == 100) {
- _index_page_cache = std::make_unique<IndexPageCache>(capacity,
num_shards);
- } else if (index_cache_percentage > 0 && index_cache_percentage < 100) {
- _data_page_cache = std::make_unique<DataPageCache>(
- capacity * (100 - index_cache_percentage) / 100, num_shards);
- _index_page_cache = std::make_unique<IndexPageCache>(
- capacity * index_cache_percentage / 100, num_shards);
- } else {
- CHECK(false) << "invalid index page cache percentage";
+ if (capacity >= num_shards * 2) { // data page cache + index page cache
+ if (index_cache_percentage == 0) {
+ _data_page_cache = std::make_unique<DataPageCache>(capacity,
num_shards);
+ } else if (index_cache_percentage == 100) {
+ _index_page_cache = std::make_unique<IndexPageCache>(capacity,
num_shards);
+ } else if (index_cache_percentage > 0 && index_cache_percentage < 100)
{
+ _data_page_cache = std::make_unique<DataPageCache>(
+ capacity * (100 - index_cache_percentage) / 100,
num_shards);
+ _index_page_cache = std::make_unique<IndexPageCache>(
+ capacity * index_cache_percentage / 100, num_shards);
+ } else {
+ CHECK(false) << "invalid index page cache percentage";
+ }
}
- if (pk_index_cache_capacity > 0) {
+ if (pk_index_cache_capacity >= num_shards) {
Review Comment:
Because it was wrong before, LRU Cache with capacity less than num_shards is
unreasonable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]