提交 b0264ee3 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Garbage collection of unused chunks should be faster still

上级 b9652f97
...@@ -37,6 +37,8 @@ Change Log ...@@ -37,6 +37,8 @@ Change Log
</li> </li>
<li>MVStoreTool: add "repair" feature. <li>MVStoreTool: add "repair" feature.
</li> </li>
<li>Garbage collection of unused chunks should be faster still.
</li>
</ul> </ul>
<h2>Version 1.4.192 Beta (2016-05-26)</h2> <h2>Version 1.4.192 Beta (2016-05-26)</h2>
......
...@@ -1056,8 +1056,11 @@ public class MVStore { ...@@ -1056,8 +1056,11 @@ public class MVStore {
long time = getTimeSinceCreation(); long time = getTimeSinceCreation();
int freeDelay = retentionTime / 10; int freeDelay = retentionTime / 10;
if (time >= lastFreeUnusedChunks + freeDelay) { if (time >= lastFreeUnusedChunks + freeDelay) {
// set early in case it fails (out of memory or so)
lastFreeUnusedChunks = time; lastFreeUnusedChunks = time;
freeUnusedChunks(); freeUnusedChunks();
// set it here as well, to avoid calling it often if it was slow
lastFreeUnusedChunks = getTimeSinceCreation();
} }
int currentUnsavedPageCount = unsavedMemory; int currentUnsavedPageCount = unsavedMemory;
long storeVersion = currentStoreVersion; long storeVersion = currentStoreVersion;
...@@ -1514,6 +1517,9 @@ public class MVStore { ...@@ -1514,6 +1517,9 @@ public class MVStore {
* @param minPercent the minimum percentage to save * @param minPercent the minimum percentage to save
*/ */
private void shrinkFileIfPossible(int minPercent) { private void shrinkFileIfPossible(int minPercent) {
if (fileStore.isReadOnly()) {
return;
}
long end = getFileLengthInUse(); long end = getFileLengthInUse();
long fileSize = fileStore.size(); long fileSize = fileStore.size();
if (end >= fileSize) { if (end >= fileSize) {
...@@ -2660,6 +2666,15 @@ public class MVStore { ...@@ -2660,6 +2666,15 @@ public class MVStore {
return cache; return cache;
} }
/**
* Whether the store is read-only.
*
* @return true if it is
*/
public boolean isReadOnly() {
return fileStore == null ? false : fileStore.isReadOnly();
}
/** /**
* A background writer thread to automatically store changes from time to * A background writer thread to automatically store changes from time to
* time. * time.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论