Repository: cassandra
Updated Branches:
  refs/heads/trunk 0c570c058 -> 48562536f


Moving getSTCSInL0CompactionCandidate out of loop to prevent useless multiple 
retrievals

Patch by Vusal Ahmadoglu; Reviewed by Jirsa for CASSANDRA-12961


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/48562536
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/48562536
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/48562536

Branch: refs/heads/trunk
Commit: 48562536f17a6e88aaf18d46e5ffa0a54c6b5be6
Parents: 0c570c0
Author: vusal-ahmadoglu <[email protected]>
Authored: Wed Sep 20 21:09:45 2017 +0200
Committer: Jeff Jirsa <[email protected]>
Committed: Mon Oct 2 17:50:13 2017 -0700

----------------------------------------------------------------------
 CHANGES.txt                                                  | 1 +
 .../org/apache/cassandra/db/compaction/LeveledManifest.java  | 8 ++++++--
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/48562536/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 2f3b106..1304f34 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 4.0
+ * LCS needlessly checks for L0 STCS candidates multiple times 
(CASSANDRA-12961)
  * Correctly close netty channels when a stream session ends (CASSANDRA-13905)
  * Update lz4 to 1.4.0 (CASSANDRA-13741)
  * Optimize Paxos prepare and propose stage for local requests 
(CASSANDRA-13862)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48562536/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java 
b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
index bafb6ee..5d1169a 100644
--- a/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
+++ b/src/java/org/apache/cassandra/db/compaction/LeveledManifest.java
@@ -345,6 +345,11 @@ public class LeveledManifest
         // This isn't a magic wand -- if you are consistently writing too fast 
for LCS to keep
         // up, you're still screwed.  But if instead you have intermittent 
bursts of activity,
         // it can help a lot.
+
+        // Let's check that L0 is far enough behind to warrant STCS.
+        // If it is, it will be used before proceeding any of higher level
+        CompactionCandidate l0Compaction = getSTCSInL0CompactionCandidate();
+
         for (int i = generations.length - 1; i > 0; i--)
         {
             List<SSTableReader> sstables = getLevel(i);
@@ -359,7 +364,6 @@ public class LeveledManifest
             if (score > 1.001)
             {
                 // before proceeding with a higher level, let's see if L0 is 
far enough behind to warrant STCS
-                CompactionCandidate l0Compaction = 
getSTCSInL0CompactionCandidate();
                 if (l0Compaction != null)
                     return l0Compaction;
 
@@ -389,7 +393,7 @@ public class LeveledManifest
             // Since we don't have any other compactions to do, see if there 
is a STCS compaction to perform in L0; if
             // there is a long running compaction, we want to make sure that 
we continue to keep the number of SSTables
             // small in L0.
-            return getSTCSInL0CompactionCandidate();
+            return l0Compaction;
         }
         return new CompactionCandidate(candidates, getNextLevel(candidates), 
maxSSTableSizeInBytes);
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to