You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2014/04/02 22:37:20 UTC

[1/3] git commit: Skip range calculations for range slices on LocalStrategy keyspaces

Repository: cassandra
Updated Branches:
  refs/heads/trunk cc66b6bea -> aa002bf81


Skip range calculations for range slices on LocalStrategy keyspaces

Patch by Tyler Hobbs; reviewed by Jonathan Ellis for CASSANDRA-6906


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

Branch: refs/heads/trunk
Commit: 133cfd399e15a2061f4759188726e875e288e625
Parents: 0e98f5b
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Apr 2 15:26:24 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Apr 2 15:26:24 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                            |  2 ++
 .../org/apache/cassandra/service/StorageProxy.java     | 13 +++++++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/133cfd39/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9003309..2f3ff42 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -44,6 +44,8 @@
  * Fix bad skip of sstables on slice query with composite start/finish (CASSANDRA-6825)
  * Fix unintended update with conditional statement (CASSANDRA-6893)
  * Fix map element access in IF (CASSANDRA-6914)
+ * Avoid costly range calculations for range queries on system keyspaces
+   (CASSANDRA-6906)
 Merged from 1.2:
  * Add UNLOGGED, COUNTER options to BATCH documentation (CASSANDRA-6816)
  * add extra SSL cipher suites (CASSANDRA-6613)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/133cfd39/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index 12f9ece..5a8dc8d 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -54,6 +54,7 @@ import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.locator.AbstractReplicationStrategy;
 import org.apache.cassandra.locator.IEndpointSnitch;
+import org.apache.cassandra.locator.LocalStrategy;
 import org.apache.cassandra.locator.TokenMetadata;
 import org.apache.cassandra.metrics.ClientRequestMetrics;
 import org.apache.cassandra.metrics.ReadRepairMetrics;
@@ -1412,8 +1413,16 @@ public class StorageProxy implements StorageProxyMBean
         try
         {
             int cql3RowCount = 0;
-            rows = new ArrayList<Row>();
-            List<AbstractBounds<RowPosition>> ranges = getRestrictedRanges(command.keyRange);
+            rows = new ArrayList<>();
+
+            // when dealing with LocalStrategy keyspaces, we can skip the range splitting and merging (which can be
+            // expensive in clusters with vnodes)
+            List<? extends AbstractBounds<RowPosition>> ranges;
+            if (keyspace.getReplicationStrategy() instanceof LocalStrategy)
+                ranges = command.keyRange.unwrap();
+            else
+                ranges = getRestrictedRanges(command.keyRange);
+
             int i = 0;
             AbstractBounds<RowPosition> nextRange = null;
             List<InetAddress> nextEndpoints = null;


[3/3] git commit: Merge branch 'cassandra-2.1' into trunk

Posted by ty...@apache.org.
Merge branch 'cassandra-2.1' into trunk


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

Branch: refs/heads/trunk
Commit: aa002bf8107baef6b514e96cdf8857bcf9d8e9ad
Parents: cc66b6b 2d60732
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Apr 2 15:37:07 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Apr 2 15:37:07 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                             |  2 ++
 src/java/org/apache/cassandra/service/StorageProxy.java | 12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/aa002bf8/CHANGES.txt
----------------------------------------------------------------------


[2/3] git commit: Merge branch 'cassandra-2.0' into cassandra-2.1

Posted by ty...@apache.org.
Merge branch 'cassandra-2.0' into cassandra-2.1

Conflicts:
	src/java/org/apache/cassandra/service/StorageProxy.java


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

Branch: refs/heads/trunk
Commit: 2d607324b3a31aa71a15c2cf9f8a4ad62deba08e
Parents: e66e523 133cfd3
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Wed Apr 2 15:36:25 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Wed Apr 2 15:36:25 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                             |  2 ++
 src/java/org/apache/cassandra/service/StorageProxy.java | 12 ++++++++++--
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d607324/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2d607324/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/service/StorageProxy.java
index 932ae25,5a8dc8d..a9d061a
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@@ -1450,21 -1413,16 +1451,28 @@@ public class StorageProxy implements St
          try
          {
              int cql3RowCount = 0;
-             rows = new ArrayList<Row>();
-             List<AbstractBounds<RowPosition>> ranges = getRestrictedRanges(command.keyRange);
+             rows = new ArrayList<>();
+ 
+             // when dealing with LocalStrategy keyspaces, we can skip the range splitting and merging (which can be
+             // expensive in clusters with vnodes)
+             List<? extends AbstractBounds<RowPosition>> ranges;
+             if (keyspace.getReplicationStrategy() instanceof LocalStrategy)
+                 ranges = command.keyRange.unwrap();
+             else
+                 ranges = getRestrictedRanges(command.keyRange);
  
 +            // our estimate of how many result rows there will be per-range
 +            float resultRowsPerRange = estimateResultRowsPerRange(command, keyspace);
 +            // underestimate how many rows we will get per-range in order to increase the likelihood that we'll
 +            // fetch enough rows in the first round
 +            resultRowsPerRange -= resultRowsPerRange * CONCURRENT_SUBREQUESTS_MARGIN;
 +            int concurrencyFactor = resultRowsPerRange == 0.0
 +                                  ? 1
 +                                  : Math.max(1, Math.min(ranges.size(), (int) Math.ceil(command.limit() / resultRowsPerRange)));
 +            logger.debug("Estimated result rows per range: {}; requested rows: {}, ranges.size(): {}; concurrent range requests: {}",
 +                         resultRowsPerRange, command.limit(), ranges.size(), concurrencyFactor);
 +
 +            boolean haveSufficientRows = false;
              int i = 0;
              AbstractBounds<RowPosition> nextRange = null;
              List<InetAddress> nextEndpoints = null;