提交 8dfa08e6 authored 作者: Thomas Mueller's avatar Thomas Mueller

Adding data to databases with a small page size is now faster.

上级 e3efaef3
...@@ -142,6 +142,11 @@ public class PageStore implements CacheWriter { ...@@ -142,6 +142,11 @@ public class PageStore implements CacheWriter {
private int freeListPagesPerList; private int freeListPagesPerList;
private boolean recoveryRunning; private boolean recoveryRunning;
/**
* The index to the first freelist page that potentially has free space.
*/
private int firstFreeListIndex;
/** /**
* The file size in bytes. * The file size in bytes.
*/ */
...@@ -1065,7 +1070,9 @@ public class PageStore implements CacheWriter { ...@@ -1065,7 +1070,9 @@ public class PageStore implements CacheWriter {
} }
private void freePage(int pageId) { private void freePage(int pageId) {
PageFreeList list = getFreeListForPage(pageId); int index = getFreeListId(pageId);
PageFreeList list = getFreeList(index);
firstFreeListIndex = Math.min(index, firstFreeListIndex);
list.free(pageId); list.free(pageId);
} }
...@@ -1117,11 +1124,11 @@ public class PageStore implements CacheWriter { ...@@ -1117,11 +1124,11 @@ public class PageStore implements CacheWriter {
private int allocatePage(BitField exclude, int first) { private int allocatePage(BitField exclude, int first) {
int page; int page;
// TODO could remember the first possible free list page for (int i = firstFreeListIndex;; i++) {
for (int i = 0;; i++) {
PageFreeList list = getFreeList(i); PageFreeList list = getFreeList(i);
page = list.allocate(exclude, first); page = list.allocate(exclude, first);
if (page >= 0) { if (page >= 0) {
firstFreeListIndex = i;
break; break;
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论