cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject [3/4] git commit: Add column update delta histogram (2.1)
Date Tue, 04 Nov 2014 20:38:56 GMT
Add column update delta histogram (2.1)

Patch by Sankalp Kohli, review by jmckenzie for CASSANDRA-7979


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

Branch: refs/heads/trunk
Commit: 5acc7a9ed72f0862cc87927014e8de131826cd23
Parents: f7f4ddb
Author: Sankalp Kohli <kohlisankalp@gmail.com>
Authored: Tue Nov 4 14:30:34 2014 -0600
Committer: Joshua McKenzie <jmckenzie@apache.org>
Committed: Tue Nov 4 14:30:34 2014 -0600

----------------------------------------------------------------------
 src/java/org/apache/cassandra/db/AtomicBTreeColumns.java    | 9 ++++++---
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java     | 4 +++-
 src/java/org/apache/cassandra/db/Memtable.java              | 9 +++++----
 .../org/apache/cassandra/metrics/ColumnFamilyMetrics.java   | 3 +++
 4 files changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/5acc7a9e/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java b/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
index 7b5e8a8..372ce5c 100644
--- a/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
+++ b/src/java/org/apache/cassandra/db/AtomicBTreeColumns.java
@@ -35,7 +35,7 @@ import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.db.composites.CellName;
 import org.apache.cassandra.db.composites.Composite;
 import org.apache.cassandra.db.filter.ColumnSlice;
-import org.apache.cassandra.utils.ObjectSizes;
+import org.apache.cassandra.utils.*;
 import org.apache.cassandra.utils.btree.BTree;
 import org.apache.cassandra.utils.btree.UpdateFunction;
 import org.apache.cassandra.utils.concurrent.Locks;
@@ -189,7 +189,7 @@ public class AtomicBTreeColumns extends ColumnFamily
      *
      * @return the difference in size seen after merging the given columns
      */
-    public long addAllWithSizeDelta(final ColumnFamily cm, MemtableAllocator allocator, OpOrder.Group
writeOp, Updater indexer)
+    public Pair<Long, Long> addAllWithSizeDelta(final ColumnFamily cm, MemtableAllocator
allocator, OpOrder.Group writeOp, Updater indexer)
     {
         ColumnUpdater updater = new ColumnUpdater(this, cm.metadata, allocator, writeOp,
indexer);
         DeletionInfo inputDeletionInfoCopy = null;
@@ -228,7 +228,7 @@ public class AtomicBTreeColumns extends ColumnFamily
                 {
                     indexer.updateRowLevelIndexes();
                     updater.finish();
-                    return updater.dataSize;
+                    return Pair.create(updater.dataSize, updater.colUpdateTimeDelta);
                 }
                 else if (!monitorOwned)
                 {
@@ -420,6 +420,7 @@ public class AtomicBTreeColumns extends ColumnFamily
         Holder ref;
         long dataSize;
         long heapSize;
+        long colUpdateTimeDelta = Long.MAX_VALUE;
         final MemtableAllocator.DataReclaimer reclaimer;
         List<Cell> inserted; // TODO: replace with walk of aborted BTree
 
@@ -458,6 +459,8 @@ public class AtomicBTreeColumns extends ColumnFamily
                     inserted = new ArrayList<>();
                 inserted.add(reconciled);
                 discard(existing);
+                //Getting the minimum delta for an update containing multiple columns
+                colUpdateTimeDelta =  Math.min(Math.abs(existing.timestamp()  - update.timestamp()),
colUpdateTimeDelta);
             }
             return reconciled;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5acc7a9e/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 184399a..0541608 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1140,9 +1140,11 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         long start = System.nanoTime();
 
         Memtable mt = data.getMemtableFor(opGroup);
-        mt.put(key, columnFamily, indexer, opGroup, replayPosition);
+        final long timeDelta = mt.put(key, columnFamily, indexer, opGroup, replayPosition);
         maybeUpdateRowCache(key);
         metric.writeLatency.addNano(System.nanoTime() - start);
+        if(timeDelta < Long.MAX_VALUE)
+            metric.colUpdateTimeDeltaHistogram.update(timeDelta);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5acc7a9e/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 b0d2a11..ba3864f 100644
--- a/src/java/org/apache/cassandra/db/Memtable.java
+++ b/src/java/org/apache/cassandra/db/Memtable.java
@@ -29,6 +29,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
 import com.google.common.base.Throwables;
+import org.apache.cassandra.utils.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,8 +44,6 @@ import org.apache.cassandra.io.sstable.SSTableWriter;
 import org.apache.cassandra.io.sstable.metadata.MetadataCollector;
 import org.apache.cassandra.io.util.DiskAwareRunnable;
 import org.apache.cassandra.service.ActiveRepairService;
-import org.apache.cassandra.utils.ByteBufferUtil;
-import org.apache.cassandra.utils.ObjectSizes;
 import org.apache.cassandra.utils.concurrent.OpOrder;
 import org.apache.cassandra.utils.memory.*;
 
@@ -151,7 +150,7 @@ public class Memtable
      *
      * replayPosition should only be null if this is a secondary index, in which case it
is *expected* to be null
      */
-    void put(DecoratedKey key, ColumnFamily cf, SecondaryIndexManager.Updater indexer, OpOrder.Group
opGroup, ReplayPosition replayPosition)
+    long put(DecoratedKey key, ColumnFamily cf, SecondaryIndexManager.Updater indexer, OpOrder.Group
opGroup, ReplayPosition replayPosition)
     {
         if (replayPosition != null && writeBarrier != null)
         {
@@ -189,8 +188,10 @@ public class Memtable
             }
         }
 
-        liveDataSize.addAndGet(previous.addAllWithSizeDelta(cf, allocator, opGroup, indexer));
+        final Pair<Long, Long> pair = previous.addAllWithSizeDelta(cf, allocator, opGroup,
indexer);
+        liveDataSize.addAndGet(pair.left);
         currentOperations.addAndGet(cf.getColumnCount() + (cf.isMarkedForDelete() ? 1 : 0)
+ cf.deletionInfo().rangeCount());
+        return pair.right;
     }
 
     // for debugging

http://git-wip-us.apache.org/repos/asf/cassandra/blob/5acc7a9e/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java b/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
index 8ab432e..d9d3ed9 100644
--- a/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/ColumnFamilyMetrics.java
@@ -101,6 +101,8 @@ public class ColumnFamilyMetrics
     public final ColumnFamilyHistogram tombstoneScannedHistogram;
     /** Live cells scanned in queries on this CF */
     public final ColumnFamilyHistogram liveScannedHistogram;
+    /** Column update time delta on this CF */
+    public final ColumnFamilyHistogram colUpdateTimeDeltaHistogram;
     /** Disk space used by snapshot files which */
     public final Gauge<Long> trueSnapshotsSize;
     /** Row cache hits, but result out of range */
@@ -497,6 +499,7 @@ public class ColumnFamilyMetrics
         });
         tombstoneScannedHistogram = createColumnFamilyHistogram("TombstoneScannedHistogram",
cfs.keyspace.metric.tombstoneScannedHistogram);
         liveScannedHistogram = createColumnFamilyHistogram("LiveScannedHistogram", cfs.keyspace.metric.liveScannedHistogram);
+        colUpdateTimeDeltaHistogram = createColumnFamilyHistogram("ColUpdateTimeDeltaHistogram",
cfs.keyspace.metric.colUpdateTimeDeltaHistogram);
         coordinatorReadLatency = Metrics.newTimer(factory.createMetricName("CoordinatorReadLatency"),
TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
         coordinatorScanLatency = Metrics.newTimer(factory.createMetricName("CoordinatorScanLatency"),
TimeUnit.MICROSECONDS, TimeUnit.SECONDS);
         waitingOnFreeMemtableSpace = Metrics.newTimer(factory.createMetricName("WaitingOnFreeMemtableSpace"),
TimeUnit.MICROSECONDS, TimeUnit.SECONDS);


Mime
View raw message