cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/3] git commit: improve compaction result logging
Date Thu, 27 Dec 2012 15:43:13 GMT
improve compaction result logging


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

Branch: refs/heads/cassandra-1.2
Commit: 26a9ab1f07a4ed20fb9e02fcb757793754a3d150
Parents: 0888a0c
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Dec 27 10:42:53 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu Dec 27 10:42:53 2012 -0500

----------------------------------------------------------------------
 .../cassandra/db/compaction/CompactionTask.java    |   23 +++++++++++---
 .../apache/cassandra/io/sstable/Descriptor.java    |    2 +-
 2 files changed, 19 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/26a9ab1f/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionTask.java b/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
index 3f6901a..e4e15bc 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionTask.java
@@ -21,9 +21,13 @@ import java.io.File;
 import java.io.IOException;
 import java.util.*;
 
+import javax.print.attribute.IntegerSyntax;
+
 import com.google.common.base.Predicates;
 import com.google.common.base.Throwables;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Iterators;
+import com.google.common.primitives.Longs;
 import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -229,20 +233,29 @@ public class CompactionTask extends AbstractCompactionTask
                key.cacheKey(entry.getKey(), entry.getValue());
         }
 
+        // log a bunch of statistics about the result
         long dTime = System.currentTimeMillis() - startTime;
         long startsize = SSTable.getTotalBytes(toCompact);
         long endsize = SSTable.getTotalBytes(sstables);
         double ratio = (double)endsize / (double)startsize;
 
         StringBuilder builder = new StringBuilder();
-        builder.append("[");
         for (SSTableReader reader : sstables)
-            builder.append(reader.getFilename()).append(",");
-        builder.append("]");
+            builder.append(reader.descriptor.baseFilename()).append(",");
 
         double mbps = dTime > 0 ? (double)endsize/(1024*1024)/((double)dTime/1000) : 0;
-        logger.info(String.format("Compacted to %s.  %,d to %,d (~%d%% of original) bytes
for %,d keys at %fMB/s.  Time: %,dms.  Compaction merge counts: %s.",
-                                  builder.toString(), startsize, endsize, (int) (ratio *
100), totalkeysWritten, mbps, dTime, Arrays.toString(ci.getMergedRowCounts())));
+        long totalSourceRows = 0;
+        String mergeSummary = "";
+        for (int i = 0; i < ci.getMergedRowCounts().length; i++)
+        {
+            int rows = i + 1;
+            int count = ci.getMergedRowCounts()[i];
+            totalSourceRows += rows * count;
+            mergeSummary += String.format("%d:%d, ", rows, count);
+        }
+
+        logger.info(String.format("Compacted %d sstables to [%s].  %,d bytes to %,d (~%d%%
of original) in %,dms = %fMB/s.  %,d total rows, %,d unique.  Row merge counts were {%s}",
+                                  toCompact.size(), builder.toString(), startsize, endsize,
(int) (ratio * 100), dTime, mbps, totalSourceRows, totalkeysWritten, mergeSummary));
         logger.debug(String.format("CF Total Bytes Compacted: %,d", CompactionTask.addToTotalBytesCompacted(endsize)));
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/26a9ab1f/src/java/org/apache/cassandra/io/sstable/Descriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/Descriptor.java b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
index a3bce13..18c8a41 100644
--- a/src/java/org/apache/cassandra/io/sstable/Descriptor.java
+++ b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
@@ -207,7 +207,7 @@ public class Descriptor
         return filenameFor(component.name());
     }
 
-    private String baseFilename()
+    public String baseFilename()
     {
         StringBuilder buff = new StringBuilder();
         buff.append(directory).append(File.separatorChar);


Mime
View raw message