average a reduced liveRatio estimate with the previous one patch by Daniel Doubleday; reviewed by jbellis for CASSANDRA-4065
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/43a472e1 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/43a472e1 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/43a472e1 Branch: refs/heads/cassandra-1.1 Commit: 43a472e13a38e4cd0420d7fb668a70464fa31ada Parents: df7776b Author: Jonathan Ellis <jbel...@apache.org> Authored: Wed Apr 18 18:13:48 2012 -0500 Committer: Jonathan Ellis <jbel...@apache.org> Committed: Wed Apr 18 18:13:48 2012 -0500 ---------------------------------------------------------------------- CHANGES.txt | 1 + src/java/org/apache/cassandra/db/Memtable.java | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/43a472e1/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index b8de41f..c6fa3d3 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 1.1-dev + * average a reduced liveRatio estimate with the previous one (CASSANDRA-4065) * Allow KS and CF names up to 48 characters (CASSANDRA-4157) * Add support for CL.TWO and CL.THREE in CQL (CASSANDRA-4156) Merged from 1.0: http://git-wip-us.apache.org/repos/asf/cassandra/blob/43a472e1/src/java/org/apache/cassandra/db/Memtable.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java index d9e9570..1eddf15 100644 --- a/src/java/org/apache/cassandra/db/Memtable.java +++ b/src/java/org/apache/cassandra/db/Memtable.java @@ -194,15 +194,21 @@ public class Memtable if (newRatio < MIN_SANE_LIVE_RATIO) { - logger.warn("setting live ratio to minimum of 1.0 instead of {}", newRatio); + logger.warn("setting live ratio to minimum of {} instead of {}", MIN_SANE_LIVE_RATIO, newRatio); newRatio = MIN_SANE_LIVE_RATIO; } if (newRatio > MAX_SANE_LIVE_RATIO) { - logger.warn("setting live ratio to maximum of 64 instead of {}", newRatio); + logger.warn("setting live ratio to maximum of {} instead of {}", MAX_SANE_LIVE_RATIO, newRatio); newRatio = MAX_SANE_LIVE_RATIO; } - cfs.liveRatio = Math.max(cfs.liveRatio, newRatio); + + // we want to be very conservative about our estimate, since the penalty for guessing low is OOM + // death. thus, higher estimates are believed immediately; lower ones are averaged w/ the old + if (newRatio > cfs.liveRatio) + cfs.liveRatio = newRatio; + else + cfs.liveRatio = (cfs.liveRatio + newRatio) / 2.0; logger.info("{} liveRatio is {} (just-counted was {}). calculation took {}ms for {} columns", new Object[]{ cfs, cfs.liveRatio, newRatio, System.currentTimeMillis() - start, objects });