You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by al...@apache.org on 2015/07/21 10:14:18 UTC
svn commit: r1692063 -
/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
Author: alexparvulescu
Date: Tue Jul 21 08:14:17 2015
New Revision: 1692063
URL: http://svn.apache.org/r1692063
Log:
OAK-3125 Skip compaction estimation if threshold is 0
Modified:
jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java?rev=1692063&r1=1692062&r2=1692063&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/segment/file/FileStore.java Tue Jul 21 08:14:17 2015
@@ -459,34 +459,51 @@ public class FileStore implements Segmen
? sum(tracker.getCompactionMap().getRecordCounts()) * PersistedCompactionMap.BYTES_PER_ENTRY
: 0;
- CompactionGainEstimate estimate = estimateCompactionGain();
- long gain = estimate.estimateCompactionGain(offset);
- if (gain >= compactionStrategy.getGainThreshold()) {
- gcMonitor.info(
- "Estimated compaction in {}, gain is {}% ({}/{}) or ({}/{}), so running compaction",
- watch, gain, estimate.getReachableSize(),
- estimate.getTotalSize(),
- humanReadableByteCount(estimate.getReachableSize()),
- humanReadableByteCount(estimate.getTotalSize()));
+ byte gainThreshold = compactionStrategy.getGainThreshold();
+ boolean runCompaction = true;
+ if (gainThreshold > 0) {
+ CompactionGainEstimate estimate = estimateCompactionGain();
+ long gain = estimate.estimateCompactionGain(offset);
+ gcMonitor
+ .info("Estimated compaction in {}, gain is {}% ({}/{}) or ({}/{}), so running compaction",
+ watch,
+ gain,
+ estimate.getReachableSize(),
+ estimate.getTotalSize(),
+ humanReadableByteCount(estimate.getReachableSize()),
+ humanReadableByteCount(estimate.getTotalSize()));
+ runCompaction = gain >= gainThreshold;
+ if (!runCompaction) {
+ if (estimate.getTotalSize() == 0) {
+ gcMonitor
+ .skipped(
+ "Estimated compaction in {}. Skipping compaction for now as repository consists of a single tar file only",
+ watch);
+ } else {
+ gcMonitor
+ .skipped(
+ "Estimated compaction in {}, gain is {}% ({}/{}) or ({}/{}), so skipping compaction for now",
+ watch, gain, estimate.getReachableSize(),
+ estimate.getTotalSize(),
+ humanReadableByteCount(estimate
+ .getReachableSize()),
+ humanReadableByteCount(estimate
+ .getTotalSize()));
+ }
+ }
+ } else {
+ gcMonitor
+ .info("Compaction estimation is skipped due to threshold value ({}).",
+ gainThreshold);
+ }
+
+ if (runCompaction) {
if (!compactionStrategy.isPaused()) {
compact();
compacted = true;
} else {
gcMonitor.skipped("TarMK compaction paused");
}
- } else {
- if (estimate.getTotalSize() == 0) {
- gcMonitor.skipped(
- "Estimated compaction in {}. Skipping compaction for now as repository " +
- "consists of a single tar file only", watch);
- } else {
- gcMonitor.skipped(
- "Estimated compaction in {}, gain is {}% ({}/{}) or ({}/{}), so skipping compaction for now",
- watch, gain, estimate.getReachableSize(),
- estimate.getTotalSize(),
- humanReadableByteCount(estimate.getReachableSize()),
- humanReadableByteCount(estimate.getTotalSize()));
- }
}
if (cleanup) {
cleanupNeeded.set(true);