You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by GitBox <gi...@apache.org> on 2021/08/11 16:04:10 UTC

[GitHub] [hbase] saintstack commented on a change in pull request #3407: HBASE-26018 Perf improvement in L1 cache - Optimistic call to buffer.retain()

saintstack commented on a change in pull request #3407:
URL: https://github.com/apache/hbase/pull/3407#discussion_r671532481



##########
File path: hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/LruAdaptiveBlockCache.java
##########
@@ -646,14 +639,16 @@ private long updateSizeMetrics(LruCachedBlock cb, boolean evict) {
   @Override
   public Cacheable getBlock(BlockCacheKey cacheKey, boolean caching, boolean repeat,
     boolean updateCacheMetrics) {
-    LruCachedBlock cb = map.computeIfPresent(cacheKey, (key, val) -> {
-      // It will be referenced by RPC path, so increase here. NOTICE: Must do the retain inside
-      // this block. because if retain outside the map#computeIfPresent, the evictBlock may remove
-      // the block and release, then we're retaining a block with refCnt=0 which is disallowed.
-      // see HBASE-22422.
-      val.getBuffer().retain();
-      return val;
-    });
+    LruCachedBlock cb = map.get(cacheKey);
+    if (cb != null) {
+      try {
+        cb.getBuffer().retain();

Review comment:
       Looking at this more....  I don't think we can do your trick afterall.
   
   The refcounting is not for the cache, it is for a backing pool of memory used reading data in from hdfs into the cache. When we evict a block from the cache, we call #release on the memory. If the refcount is zero, the memory is released and can be reused in the backing pool. If #release is called and the #refcount is not zero, we just decrement the refcount.
   
   A cached buffer item detached from the cache still needs to have its #release called w/ refcount at zero so the backing memory gets readded to the pool.
   
   So it seems to me. What you think @virajjasani 




-- 
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: issues-unsubscribe@hbase.apache.org

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