提交 5375ed8d authored 作者: Thomas Mueller's avatar Thomas Mueller

Don't try to compact if there are no old chunks

上级 22010076
...@@ -1676,10 +1676,21 @@ public class MVStore { ...@@ -1676,10 +1676,21 @@ public class MVStore {
// calculate the fill rate // calculate the fill rate
long maxLengthSum = 0; long maxLengthSum = 0;
long maxLengthLiveSum = 0; long maxLengthLiveSum = 0;
long time = getTime();
for (Chunk c : chunks.values()) { for (Chunk c : chunks.values()) {
// ignore young chunks, because we don't optimize those
if (c.time + retentionTime > time) {
continue;
}
maxLengthSum += c.maxLen; maxLengthSum += c.maxLen;
maxLengthLiveSum += c.maxLenLive; maxLengthLiveSum += c.maxLenLive;
} }
if (maxLengthLiveSum < 0) {
// no old data
return null;
}
// the fill rate of all chunks combined // the fill rate of all chunks combined
if (maxLengthSum <= 0) { if (maxLengthSum <= 0) {
// avoid division by 0 // avoid division by 0
...@@ -1690,8 +1701,6 @@ public class MVStore { ...@@ -1690,8 +1701,6 @@ public class MVStore {
return null; return null;
} }
long time = getTime();
// the 'old' list contains the chunks we want to free up // the 'old' list contains the chunks we want to free up
ArrayList<Chunk> old = New.arrayList(); ArrayList<Chunk> old = New.arrayList();
Chunk last = chunks.get(lastChunk.id); Chunk last = chunks.get(lastChunk.id);
...@@ -1699,12 +1708,13 @@ public class MVStore { ...@@ -1699,12 +1708,13 @@ public class MVStore {
// only look at chunk older than the retention time // only look at chunk older than the retention time
// (it's possible to compact chunks earlier, but right // (it's possible to compact chunks earlier, but right
// now we don't do that) // now we don't do that)
if (c.time + retentionTime <= time) { if (c.time + retentionTime > time) {
continue;
}
long age = last.version - c.version + 1; long age = last.version - c.version + 1;
c.collectPriority = (int) (c.getFillRate() * 1000 / age); c.collectPriority = (int) (c.getFillRate() * 1000 / age);
old.add(c); old.add(c);
} }
}
if (old.size() == 0) { if (old.size() == 0) {
return null; return null;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论