cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1144586 - in /cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction: CompactionController.java CompactionIterator.java
Date Sat, 09 Jul 2011 03:34:02 GMT
Author: jbellis
Date: Sat Jul  9 03:34:02 2011
New Revision: 1144586

URL: http://svn.apache.org/viewvc?rev=1144586&view=rev
Log:
make throttle resolution finer grained, especially for large rows
patch by jbellis

Modified:
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionController.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionController.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionController.java?rev=1144586&r1=1144585&r2=1144586&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionController.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionController.java
Sat Jul  9 03:34:02 2011
@@ -46,6 +46,7 @@ public class CompactionController
 
     public final boolean isMajor;
     public final int gcBefore;
+    private int throttleResolution;
 
     public CompactionController(ColumnFamilyStore cfs, Collection<SSTableReader> sstables,
int gcBefore, boolean forceDeserialize)
     {
@@ -55,15 +56,22 @@ public class CompactionController
         this.gcBefore = gcBefore;
         this.forceDeserialize = forceDeserialize;
         isMajor = cfs.isCompleteSSTables(this.sstables);
+        // how many rows we expect to compact in 100ms
+        throttleResolution = (int) (DatabaseDescriptor.getCompactionThroughputMbPerSec()
* 1024 * 1024 / (10 * cfs.getMeanRowSize()));
+        if (throttleResolution <= 0)
+            throttleResolution = 1;
+    }
+
+    public int getThrottleResolution()
+    {
+        return throttleResolution;
     }
 
-    /** @return the keyspace name */
     public String getKeyspace()
     {
         return cfs.table.name;
     }
 
-    /** @return the column family name */
     public String getColumnFamily()
     {
         return cfs.columnFamily;

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java?rev=1144586&r1=1144585&r2=1144586&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/compaction/CompactionIterator.java
Sat Jul  9 03:34:02 2011
@@ -137,13 +137,11 @@ implements Closeable, CompactionInfo.Hol
         finally
         {
             rows.clear();
-            if ((row++ % 1000) == 0)
+            if ((row++ % controller.getThrottleResolution()) == 0)
             {
                 bytesRead = 0;
                 for (SSTableScanner scanner : getScanners())
-                {
                     bytesRead += scanner.getFilePointer();
-                }
                 throttle();
             }
         }
@@ -164,9 +162,7 @@ implements Closeable, CompactionInfo.Hol
         int newTarget = totalBytesPerMS /
             Math.max(1, CompactionManager.instance.getActiveCompactions());
         if (newTarget != targetBytesPerMS)
-            logger.info(String.format("%s now compacting at %d bytes/ms.",
-                                      this,
-                                      newTarget));
+            logger.debug("{} now compacting at {} bytes/ms.", this, newTarget);
         targetBytesPerMS = newTarget;
 
         // the excess bytes that were compacted in this period
@@ -179,7 +175,14 @@ implements Closeable, CompactionInfo.Hol
             if (logger.isTraceEnabled())
                 logger.trace(String.format("Compacted %d bytes in %d ms: throttling for %d
ms",
                                            bytesSinceLast, msSinceLast, timeToDelay));
-            try { Thread.sleep(timeToDelay); } catch (InterruptedException e) { throw new
AssertionError(e); }
+            try
+            {
+                Thread.sleep(timeToDelay);
+            }
+            catch (InterruptedException e)
+            {
+                throw new AssertionError(e);
+            }
         }
         bytesAtLastDelay = bytesRead;
         timeAtLastDelay = System.currentTimeMillis();



Mime
View raw message