Browse Source

add print of rocksdb3

tags/1.1.10
shaozhuguang 5 years ago
parent
commit
11139f4001
1 changed files with 11 additions and 24 deletions
  1. +11
    -24
      source/storage/storage-rocksdb/src/main/java/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBConnectionFactory.java

+ 11
- 24
source/storage/storage-rocksdb/src/main/java/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBConnectionFactory.java View File

@@ -93,8 +93,8 @@ public class RocksDBConnectionFactory implements DbConnectionFactory {
}

private Options initOptionsByProperties(Properties dbProperties) {
long cacheCapacity = getLong(dbProperties, "cache.capacity", 512 * SizeUnit.MB);
int cacheNumShardBits = getInt(dbProperties, "cache.numShardBits", 64);
long cacheCapacity = getLong(dbProperties, "cache.capacity", 1024 * SizeUnit.MB);
int cacheNumShardBits = getInt(dbProperties, "cache.numShardBits", 128);

long tableBlockSize = getLong(dbProperties, "table.blockSize", 4 * SizeUnit.KB);
long tableMetadataBlockSize = getLong(dbProperties, "table.metadata.blockSize", 4 * SizeUnit.KB);
@@ -107,43 +107,30 @@ public class RocksDBConnectionFactory implements DbConnectionFactory {
int optionMaxBackgroundCompactions = getInt(dbProperties, "option.maxBackgroundCompactions", 5);
int optionMaxBackgroundFlushes = getInt(dbProperties, "option.maxBackgroundFlushes", 4);

System.out.printf("cacheCapacity = %s \r\n", cacheCapacity);
System.out.printf("cacheNumShardBits = %s \r\n", cacheNumShardBits);
System.out.printf("tableBlockSize = %s \r\n", tableBlockSize);
System.out.printf("tableMetadataBlockSize = %s \r\n", tableMetadataBlockSize);
System.out.printf("tableBloomBitsPerKey = %s \r\n", tableBloomBitsPerKey);
System.out.printf("optionWriteBufferSize = %s \r\n", optionWriteBufferSize);
System.out.printf("optionMaxWriteBufferNumber = %s \r\n", optionMaxWriteBufferNumber);

System.out.printf("optionMinWriteBufferNumberToMerge = %s \r\n", optionMinWriteBufferNumberToMerge);
System.out.printf("optionMaxOpenFiles = %s \r\n", optionMaxOpenFiles);
System.out.printf("optionMaxBackgroundCompactions = %s \r\n", optionMaxBackgroundCompactions);
System.out.printf("optionMaxBackgroundFlushes = %s \r\n", optionMaxBackgroundFlushes);

Cache cache = new LRUCache(512 * SizeUnit.MB, 64, false);
Cache cache = new LRUCache(cacheCapacity, cacheNumShardBits, false);

final BlockBasedTableConfig tableOptions = new BlockBasedTableConfig()
.setBlockCache(cache)
.setMetadataBlockSize(4096)
.setMetadataBlockSize(tableMetadataBlockSize)
.setCacheIndexAndFilterBlocks(true) // 设置索引和布隆过滤器使用Block Cache内存
.setCacheIndexAndFilterBlocksWithHighPriority(true)
.setIndexType(IndexType.kTwoLevelIndexSearch) // 设置两级索引,控制索引占用内存
.setPinTopLevelIndexAndFilter(false)
.setBlockSize(4096)
.setBlockSize(tableBlockSize)
.setFilterPolicy(null) // 不设置布隆过滤器
;

Options options = new Options()
// 最多占用256 * 6 + 512 = 2G内存
.setWriteBufferSize(256 * SizeUnit.MB)
.setMaxWriteBufferNumber(6)
.setMinWriteBufferNumberToMerge(2)
.setMaxOpenFiles(100) // 控制最大打开文件数量,防止内存持续增加
.setWriteBufferSize(optionWriteBufferSize)
.setMaxWriteBufferNumber(optionMaxWriteBufferNumber)
.setMinWriteBufferNumberToMerge(optionMinWriteBufferNumberToMerge)
.setMaxOpenFiles(optionMaxOpenFiles) // 控制最大打开文件数量,防止内存持续增加
.setAllowConcurrentMemtableWrite(true) //允许并行Memtable写入
.setCreateIfMissing(true)
.setTableFormatConfig(tableOptions)
.setMaxBackgroundCompactions(5)
.setMaxBackgroundFlushes(4)
.setMaxBackgroundCompactions(optionMaxBackgroundCompactions)
.setMaxBackgroundFlushes(optionMaxBackgroundFlushes)
;
return options;
}


Loading…
Cancel
Save