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 2022/07/21 18:37:26 UTC

[accumulo] branch main updated: Modify CompactionCheck logic to run complex checks less often (#2804)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new e68de3c291 Modify CompactionCheck logic to run complex checks less often (#2804)
e68de3c291 is described below

commit e68de3c291d09c75e45b1c409cb8e6d1a519727f
Author: Dave Marion <dl...@apache.org>
AuthorDate: Thu Jul 21 14:37:21 2022 -0400

    Modify CompactionCheck logic to run complex checks less often (#2804)
    
    This change splits the prior memoized check into two, one that
    is less complex and is checked more often and one that is more
    complex, likely to change less often and is checked less often
    
    Closes #1610
---
 .../accumulo/tserver/tablet/CompactableImpl.java     | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java
index c8275b5ad5..8345a85052 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/CompactableImpl.java
@@ -1105,23 +1105,23 @@ public class CompactableImpl implements Compactable {
   }
 
   class CompactionCheck {
-    private final Supplier<Boolean> memoizedCheck;
+    private final Supplier<Boolean> expensiveCheck;
+    private final Supplier<Boolean> inexpensiveCheck;
 
     public CompactionCheck(CompactionServiceId service, CompactionKind kind, Long compactionId) {
-      this.memoizedCheck = Suppliers.memoizeWithExpiration(() -> {
-        if (closed)
+      this.expensiveCheck = Suppliers.memoizeWithExpiration(() -> {
+        return service.equals(getConfiguredService(kind));
+      }, 3, TimeUnit.SECONDS);
+      this.inexpensiveCheck = Suppliers.memoizeWithExpiration(() -> {
+        if (closed
+            || (kind == CompactionKind.USER && lastSeenCompactionCancelId.get() >= compactionId))
           return false;
-        if (!service.equals(getConfiguredService(kind)))
-          return false;
-        if (kind == CompactionKind.USER && lastSeenCompactionCancelId.get() >= compactionId)
-          return false;
-
         return true;
-      }, 100, TimeUnit.MILLISECONDS);
+      }, 50, TimeUnit.MILLISECONDS);
     }
 
     public boolean isCompactionEnabled() {
-      return memoizedCheck.get();
+      return inexpensiveCheck.get() && expensiveCheck.get();
     }
   }