You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by dl...@apache.org on 2023/02/06 12:36:42 UTC

[accumulo] branch 2.1 updated: Increased number of locks in SynchronousLoadingBlockCache and set them to be fair (#3175)

This is an automated email from the ASF dual-hosted git repository.

dlmarion pushed a commit to branch 2.1
in repository https://gitbox.apache.org/repos/asf/accumulo.git


The following commit(s) were added to refs/heads/2.1 by this push:
     new 7fe966cdfc Increased number of locks in SynchronousLoadingBlockCache and set them to be fair (#3175)
7fe966cdfc is described below

commit 7fe966cdfcf7721d7ae40de41dd96cf8d1c7f559
Author: Dave Marion <dl...@apache.org>
AuthorDate: Mon Feb 6 07:36:35 2023 -0500

    Increased number of locks in SynchronousLoadingBlockCache and set them to be fair (#3175)
    
    SynchronousLoadingBlockCache was introduced in ACCUMULO-4641. The code in this class
    used to be located in LruBlockCache. In ACCUMULO-4641 the number of load locks was
    reduced from 5003 to 2017. There is no comment as to why this was done, but it was
    something I noticed while looking at the fairness of the load locks. This commit resets
    the default size back to 5003, as it was in 1.10.x. This commit also changes the load
    locks to be fair, which allows the different scan threads in the tablet / scan server
    to make progress when there is a collision and multiple threads use the same lock.
---
 .../core/file/blockfile/cache/lru/SynchronousLoadingBlockCache.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/SynchronousLoadingBlockCache.java b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/SynchronousLoadingBlockCache.java
index 3ed7c88cde..df27c290ca 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/SynchronousLoadingBlockCache.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/blockfile/cache/lru/SynchronousLoadingBlockCache.java
@@ -43,12 +43,12 @@ public abstract class SynchronousLoadingBlockCache implements BlockCache {
   SynchronousLoadingBlockCache(int numLocks) {
     loadLocks = new Lock[numLocks];
     for (int i = 0; i < loadLocks.length; i++) {
-      loadLocks[i] = new ReentrantLock();
+      loadLocks[i] = new ReentrantLock(true);
     }
   }
 
   public SynchronousLoadingBlockCache() {
-    this(2017);
+    this(5003);
   }
 
   private Map<String,byte[]> resolveDependencies(Map<String,Loader> loaderDeps) {
@@ -113,8 +113,8 @@ public abstract class SynchronousLoadingBlockCache implements BlockCache {
     int lockIndex = (blockName.hashCode() & 0x7fffffff) % loadLocks.length;
     Lock loadLock = loadLocks[lockIndex];
 
+    loadLock.lock();
     try {
-      loadLock.lock();
 
       // check again after getting lock, could have loaded while waiting on lock
       ce = getBlockNoStats(blockName);