You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/12/27 15:33:02 UTC
[1/3] git commit: Improve handling a changing target throttle rate
mid-compaction patch by J.B. Langston; reviewed by jbellis for CASSANDRA-5087
Improve handling a changing target throttle rate mid-compaction
patch by J.B. Langston; reviewed by jbellis for CASSANDRA-5087
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e19cdaa1
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e19cdaa1
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e19cdaa1
Branch: refs/heads/cassandra-1.2
Commit: e19cdaa1f1c7eee106417ea8fa80058157db8720
Parents: 38757c4
Author: Jonathan Ellis <jb...@apache.org>
Authored: Thu Dec 27 09:32:38 2012 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Thu Dec 27 09:32:38 2012 -0500
----------------------------------------------------------------------
CHANGES.txt | 1 +
src/java/org/apache/cassandra/utils/Throttle.java | 14 +++++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e19cdaa1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 404cdbe..2061c29 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
1.2.1
+ * Improve handling a changing target throttle rate mid-compaction (CASSANDRA-5087)
* fix hinting for dropped local writes (CASSANDRA-4753)
* off-heap cache doesn't need mutable column container (CASSANDRA-5057)
* apply disk_failure_policy to bad disks on initial directory creation
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e19cdaa1/src/java/org/apache/cassandra/utils/Throttle.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/Throttle.java b/src/java/org/apache/cassandra/utils/Throttle.java
index 07d2400..c3d643c 100644
--- a/src/java/org/apache/cassandra/utils/Throttle.java
+++ b/src/java/org/apache/cassandra/utils/Throttle.java
@@ -51,7 +51,7 @@ public class Throttle
throttleDelta(currentBytes - bytesAtLastDelay);
}
- /** @param bytesDelta Bytes of throughput since the last call to throttle*(). */
+ /** @param bytesDelta Bytes of throughput since the last call to throttle*() */
public void throttleDelta(long bytesDelta)
{
int newTargetBytesPerMS = fun.targetThroughput();
@@ -59,10 +59,18 @@ public class Throttle
// throttling disabled
return;
- // if the target changed, log
if (newTargetBytesPerMS != targetBytesPerMS)
+ {
+ // restart throttling based on the new target to avoid getting bogus answers based on comparing
+ // the rate under the old throttle, with the desired rate under the new. (If the new rate is higher
+ // than the old, it doesn't much matter, but if the new rate is lower, it would result in a long
+ // sleep to bring the average down. See CASSANDRA-5087.)
logger.debug("{} target throughput now {} bytes/ms.", this, newTargetBytesPerMS);
- targetBytesPerMS = newTargetBytesPerMS;
+ targetBytesPerMS = newTargetBytesPerMS;
+ bytesAtLastDelay += bytesDelta;
+ timeAtLastDelay = System.currentTimeMillis();
+ return;
+ }
// time passed since last delay
long msSinceLast = System.currentTimeMillis() - timeAtLastDelay;