Browse Source

add print of rocksdb3

tags/1.1.10
shaozhuguang 5 years ago
parent
commit
7315c8a285
1 changed files with 26 additions and 21 deletions
  1. +26
    -21
      source/storage/storage-rocksdb/src/main/java/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBConnectionFactory.java

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

@@ -120,27 +120,32 @@ public class RocksDBConnectionFactory implements DbConnectionFactory {
System.out.printf("optionMaxBackgroundCompactions = %s \r\n", optionMaxBackgroundCompactions);
System.out.printf("optionMaxBackgroundFlushes = %s \r\n", optionMaxBackgroundFlushes);

Cache cache = new LRUCache(512 * SizeUnit.MB);

final BlockBasedTableConfig tableOptions = new BlockBasedTableConfig()
.setBlockCache(cache)
.setCacheIndexAndFilterBlocks(true)
;

Options options = new Options()
// 最多占用256 * 7 + 512 = 2.25G内存
.setWriteBufferSize(256 * SizeUnit.MB)
.setMaxWriteBufferNumber(7)
.setMinWriteBufferNumberToMerge(2)
.setMaxOpenFiles(-1)
.setAllowConcurrentMemtableWrite(true)
.setCreateIfMissing(true)
.setTableFormatConfig(tableOptions)
.setMaxBackgroundCompactions(5)
.setMaxBackgroundFlushes(4)
.setMemTableConfig(new SkipListMemTableConfig())
;
return options;
Cache cache = new LRUCache(512 * SizeUnit.MB, 64, false);

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

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

/**


Loading…
Cancel
Save