Repository: cassandra Updated Branches: refs/heads/cassandra-3.11 515f07b5a -> 0ab9fc4b7 refs/heads/trunk f74b0ea75 -> a75b48ba5
RateBasedBackPressure unnecessarily invokes a lock on the Guava RateLimiter patch by Nate McCall; reviewed by jasobrown for CASSANDRA-14163 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/0ab9fc4b Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/0ab9fc4b Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/0ab9fc4b Branch: refs/heads/cassandra-3.11 Commit: 0ab9fc4b73eeadff369435bcdf8b03310a34940c Parents: 515f07b Author: Nate McCall <zznat...@gmail.com> Authored: Sat Feb 17 07:29:17 2018 -0800 Committer: Jason Brown <jasedbr...@gmail.com> Committed: Sat Feb 17 07:29:17 2018 -0800 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/net/RateBasedBackPressure.java | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ab9fc4b/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index e858781..022807f 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.11.3 + * RateBasedBackPressure unnecessarily invokes a lock on the Guava RateLimiter (CASSANDRA-14163) * Fix wildcard GROUP BY queries (CASSANDRA-14209) Merged from 2.1 * CVE-2017-5929 Security vulnerability in Logback warning in NEWS.txt (CASSANDRA-14183) http://git-wip-us.apache.org/repos/asf/cassandra/blob/0ab9fc4b/src/java/org/apache/cassandra/net/RateBasedBackPressure.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/net/RateBasedBackPressure.java b/src/java/org/apache/cassandra/net/RateBasedBackPressure.java index 1dae243..565bf4c 100644 --- a/src/java/org/apache/cassandra/net/RateBasedBackPressure.java +++ b/src/java/org/apache/cassandra/net/RateBasedBackPressure.java @@ -161,12 +161,13 @@ public class RateBasedBackPressure implements BackPressureStrategy<RateBasedBack double actualRatio = incomingRate / outgoingRate; // If the ratio is above the high mark, try growing by the back-pressure factor: + double limiterRate = limiter.getRate(); if (actualRatio >= highRatio) { // Only if the outgoing rate is able to keep up with the rate increase: - if (limiter.getRate() <= outgoingRate) + if (limiterRate <= outgoingRate) { - double newRate = limiter.getRate() + ((limiter.getRate() * factor) / 100); + double newRate = limiterRate + ((limiterRate * factor) / 100); if (newRate > 0 && newRate != Double.POSITIVE_INFINITY) { limiter.setRate(newRate); @@ -178,14 +179,16 @@ public class RateBasedBackPressure implements BackPressureStrategy<RateBasedBack { // Only if the new rate is actually less than the actual rate: double newRate = incomingRate - ((incomingRate * factor) / 100); - if (newRate > 0 && newRate < limiter.getRate()) + if (newRate > 0 && newRate < limiterRate) { limiter.setRate(newRate); } } - - logger.trace("Back-pressure state for {}: incoming rate {}, outgoing rate {}, ratio {}, rate limiting {}", - backPressure.getHost(), incomingRate, outgoingRate, actualRatio, limiter.getRate()); + if (logger.isTraceEnabled()) + { + logger.trace("Back-pressure state for {}: incoming rate {}, outgoing rate {}, ratio {}, rate limiting {}", + backPressure.getHost(), incomingRate, outgoingRate, actualRatio, limiter.getRate()); + } } // Otherwise reset the rate limiter: else --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org