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 maxOpenFiles: -int
blockCache: -long blockCache: -long
compressedBlockCache: -long compressedBlockCache: -long
writeBufferManager: -long
spinning: boolean spinning: boolean
defaultColumnOptions: DefaultColumnOptions defaultColumnOptions: DefaultColumnOptions
columnOptions: NamedColumnOptions[] columnOptions: NamedColumnOptions[]

View File

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

View File

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