Repository: cassandra Updated Branches: refs/heads/trunk 37f517593 -> 7036e39af
Stop inheriting liveRatio and liveRatioComputedAt from previous memtables patch by Aleksey Yeschenko; reviewed by Jonathan Ellis for CASSANDRA-7796 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/eeb0d4c9 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/eeb0d4c9 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/eeb0d4c9 Branch: refs/heads/trunk Commit: eeb0d4c90198b14113ee094587cf0eacceb2b96f Parents: 76adf0e Author: Aleksey Yeschenko <alek...@apache.org> Authored: Wed Aug 20 15:40:27 2014 +0300 Committer: Aleksey Yeschenko <alek...@apache.org> Committed: Wed Aug 20 15:40:27 2014 +0300 ---------------------------------------------------------------------- CHANGES.txt | 2 ++ src/java/org/apache/cassandra/db/DataTracker.java | 6 +++--- src/java/org/apache/cassandra/db/Memtable.java | 14 +++----------- 3 files changed, 8 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/eeb0d4c9/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index c8f7591..2b2930e 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,6 @@ 2.0.10 + * Stop inheriting liveRatio and liveRatioComputedAt from previous + memtables (CASSANDRA-7796) * Throw EOFException if we run out of chunks in compressed datafile (CASSANDRA-7664) * Throw InvalidRequestException when queries contain relations on entire http://git-wip-us.apache.org/repos/asf/cassandra/blob/eeb0d4c9/src/java/org/apache/cassandra/db/DataTracker.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/DataTracker.java b/src/java/org/apache/cassandra/db/DataTracker.java index 088255e..05ee13e 100644 --- a/src/java/org/apache/cassandra/db/DataTracker.java +++ b/src/java/org/apache/cassandra/db/DataTracker.java @@ -109,7 +109,7 @@ public class DataTracker public Memtable switchMemtable() { // atomically change the current memtable - Memtable newMemtable = new Memtable(cfstore, view.get().memtable); + Memtable newMemtable = new Memtable(cfstore); Memtable toFlushMemtable; View currentView, newView; do @@ -132,7 +132,7 @@ public class DataTracker { assert !cfstore.keyspace.metadata.durableWrites; - Memtable newMemtable = new Memtable(cfstore, view.get().memtable); + Memtable newMemtable = new Memtable(cfstore); View currentView, newView; do { @@ -323,7 +323,7 @@ public class DataTracker /** (Re)initializes the tracker, purging all references. */ void init() { - view.set(new View(new Memtable(cfstore, null), + view.set(new View(new Memtable(cfstore), Collections.<Memtable>emptySet(), Collections.<SSTableReader>emptySet(), Collections.<SSTableReader>emptySet(), http://git-wip-us.apache.org/repos/asf/cassandra/blob/eeb0d4c9/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 20adeb7..f9a6719 100644 --- a/src/java/org/apache/cassandra/db/Memtable.java +++ b/src/java/org/apache/cassandra/db/Memtable.java @@ -120,20 +120,12 @@ public class Memtable // memtable was created with the new or old comparator. public final AbstractType initialComparator; - public Memtable(ColumnFamilyStore cfs, Memtable previous) + public Memtable(ColumnFamilyStore cfs) { this.cfs = cfs; this.initialComparator = cfs.metadata.comparator; this.cfs.scheduleFlush(); - // Inherit liveRatio and liveRatioCompareAt from the previous memtable, if available, - // to minimise recalculation frequency as much as possible. - if (previous != null) - { - liveRatio = previous.liveRatio; - liveRatioComputedAt.set(previous.liveRatioComputedAt.get() / 4); - } - Callable<Set<Object>> provider = new Callable<Set<Object>>() { public Set<Object> call() throws Exception @@ -175,12 +167,12 @@ public class Memtable public void maybeUpdateLiveRatio() { - // recompute liveRatio, if we have doubled the number of ops since last calculated + // recompute liveRatio, if we have increased the number of ops 10x since last calculated while (true) { long last = liveRatioComputedAt.get(); long operations = currentOperations.get(); - if (operations <= 2L * last) + if (operations <= 10L * last) break; if (liveRatioComputedAt.compareAndSet(last, operations)) {