JackDrogon commented on code in PR #31122:
URL: https://github.com/apache/doris/pull/31122#discussion_r1495519607


##########
be/src/runtime/memory/lru_cache_policy.h:
##########
@@ -84,26 +76,24 @@ class LRUCachePolicy : public CachePolicy {
 
     // Try to prune the cache if expired.
     void prune_stale() override {
+        COUNTER_SET(_freed_entrys_counter, (int64_t)0);

Review Comment:
   use 0LL replace (int64_t) 0



##########
be/src/olap/lru_cache.cpp:
##########
@@ -622,20 +629,27 @@ uint64_t ShardedLRUCache::new_id() {
     return _last_id.fetch_add(1, std::memory_order_relaxed);
 }
 
-int64_t ShardedLRUCache::prune() {
-    int64_t num_prune = 0;
+std::tuple<PrunedCount, PrunedSize> ShardedLRUCache::prune() {

Review Comment:
   use range_view algorithm replace for



##########
be/src/olap/lru_cache.h:
##########
@@ -219,12 +222,15 @@ class Cache {
     // encouraged to override the default implementation.  A future release of
     // leveldb may change prune() to a pure abstract method.
     // return num of entries being pruned.
-    virtual int64_t prune() { return 0; }
+    virtual std::tuple<PrunedCount, PrunedSize> prune() { return {0, 0}; }

Review Comment:
   use struct not tuple



##########
be/src/olap/lru_cache.cpp:
##########
@@ -622,20 +629,27 @@ uint64_t ShardedLRUCache::new_id() {
     return _last_id.fetch_add(1, std::memory_order_relaxed);
 }
 
-int64_t ShardedLRUCache::prune() {
-    int64_t num_prune = 0;
+std::tuple<PrunedCount, PrunedSize> ShardedLRUCache::prune() {
+    int64_t pruned_count = 0;
+    int64_t pruned_size = 0;
     for (int s = 0; s < _num_shards; s++) {
-        num_prune += _shards[s]->prune();
+        auto [count, size] = _shards[s]->prune();
+        pruned_count += count;
+        pruned_size += size;
     }
-    return num_prune;
+    return {pruned_count, pruned_size};
 }
 
-int64_t ShardedLRUCache::prune_if(CacheValuePredicate pred, bool lazy_mode) {
-    int64_t num_prune = 0;
+std::tuple<PrunedCount, PrunedSize> 
ShardedLRUCache::prune_if(CachePrunePredicate pred,
+                                                              bool lazy_mode) {
+    int64_t pruned_count = 0;
+    int64_t pruned_size = 0;
     for (int s = 0; s < _num_shards; s++) {

Review Comment:
   use range_view algorithm replace for



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to