Configurable write buffer manager

This commit is contained in:
Andrea Cavalli 2022-04-11 16:53:17 +02:00
parent 4448947cfd
commit d35840ec03
3 changed files with 24 additions and 5 deletions

View File

@ -247,6 +247,7 @@ versions:
maxOpenFiles: -int
blockCache: -long
compressedBlockCache: -long
writeBufferManager: -long
spinning: boolean
defaultColumnOptions: DefaultColumnOptions
columnOptions: NamedColumnOptions[]

View File

@ -46,6 +46,7 @@ public class DefaultDatabaseOptions {
Nullableint.empty(),
Nullablelong.empty(),
Nullablelong.empty(),
Nullablelong.empty(),
false,
DEFAULT_DEFAULT_COLUMN_OPTIONS,
List.of()

View File

@ -613,6 +613,13 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
options.setUseFsync(false);
}
long writeBufferManagerSize;
if (databaseOptions.writeBufferManager().isPresent()) {
writeBufferManagerSize = databaseOptions.writeBufferManager().get();
} else {
writeBufferManagerSize = 0;
}
Cache blockCache;
Cache compressedCache;
if (databaseOptions.lowMemory()) {
@ -627,8 +634,12 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
.setMaxTotalWalSize(0) // automatic
;
// DO NOT USE ClockCache! IT'S BROKEN!
blockCache = new LRUCache(databaseOptions.blockCache().orElse( 8L * SizeUnit.MB));
compressedCache = new LRUCache(databaseOptions.compressedBlockCache().orElse( 8L * SizeUnit.MB));
blockCache = new LRUCache(writeBufferManagerSize + databaseOptions.blockCache().orElse( 8L * SizeUnit.MB));
if (databaseOptions.compressedBlockCache().isPresent()) {
compressedCache = new LRUCache(databaseOptions.compressedBlockCache().get());
} else {
compressedCache = null;
}
if (databaseOptions.spinning()) {
options
@ -658,8 +669,12 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
.setMaxTotalWalSize(80 * SizeUnit.MB) // 80MiB max wal directory size
;
// DO NOT USE ClockCache! IT'S BROKEN!
blockCache = new LRUCache(databaseOptions.blockCache().orElse( 512 * SizeUnit.MB));
compressedCache = new LRUCache(databaseOptions.compressedBlockCache().orElse( 512 * SizeUnit.MB));
blockCache = new LRUCache(writeBufferManagerSize + databaseOptions.blockCache().orElse( 512 * SizeUnit.MB));
if (databaseOptions.compressedBlockCache().isPresent()) {
compressedCache = new LRUCache(databaseOptions.compressedBlockCache().get());
} else {
compressedCache = null;
}
if (databaseOptions.useDirectIO()) {
options
@ -674,7 +689,9 @@ public class LLLocalKeyValueDatabase implements LLKeyValueDatabase {
}
options.setRowCache(blockCache);
options.setWriteBufferManager(new WriteBufferManager(256L * 1024L * 1024L, blockCache));
if (databaseOptions.writeBufferManager().isPresent()) {
options.setWriteBufferManager(new WriteBufferManager(writeBufferManagerSize, blockCache));
}
if (databaseOptions.useDirectIO()) {
options