Browse Source

modify args of rocksdb config

tags/1.1.5
shaozhuguang 5 years ago
parent
commit
bd9b4c80d1
1 changed files with 3 additions and 22 deletions
  1. +3
    -22
      source/storage/storage-rocksdb/src/main/java/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBConnectionFactory.java

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

@@ -85,43 +85,24 @@ public class RocksDBConnectionFactory implements DbConnectionFactory {
} }


private Options initOptions() { private Options initOptions() {
final Filter bloomFilter = new BloomFilter(10);
Cache cache = new LRUCache(256 * SizeUnit.MB);
Cache cache = new LRUCache(512 * SizeUnit.MB);


final BlockBasedTableConfig tableOptions = new BlockBasedTableConfig() final BlockBasedTableConfig tableOptions = new BlockBasedTableConfig()
.setFilterPolicy(bloomFilter)
.setBlockSizeDeviation(10)
.setBlockCache(cache) .setBlockCache(cache)
.setNoBlockCache(false)
.setCacheIndexAndFilterBlocks(true) .setCacheIndexAndFilterBlocks(true)
.setBlockRestartInterval(16)
; ;
final List<CompressionType> compressionLevels = new ArrayList<>();
compressionLevels.add(CompressionType.NO_COMPRESSION); // 0-1
compressionLevels.add(CompressionType.SNAPPY_COMPRESSION); // 1-2
compressionLevels.add(CompressionType.SNAPPY_COMPRESSION); // 2-3
compressionLevels.add(CompressionType.SNAPPY_COMPRESSION); // 3-4
compressionLevels.add(CompressionType.SNAPPY_COMPRESSION); // 4-5
compressionLevels.add(CompressionType.SNAPPY_COMPRESSION); // 5-6
compressionLevels.add(CompressionType.SNAPPY_COMPRESSION); // 6-7


Options options = new Options() Options options = new Options()
// 最多占用256 * 7 + 256 = 2G内存
// 最多占用256 * 7 + 512 = 2.25G内存
.setWriteBufferSize(256 * SizeUnit.MB) .setWriteBufferSize(256 * SizeUnit.MB)
.setMaxWriteBufferNumber(7) .setMaxWriteBufferNumber(7)
.setMinWriteBufferNumberToMerge(2) .setMinWriteBufferNumberToMerge(2)
.setMaxOpenFiles(-1) .setMaxOpenFiles(-1)
.setAllowConcurrentMemtableWrite(true) .setAllowConcurrentMemtableWrite(true)
.setEnableWriteThreadAdaptiveYield(true)
.setCreateIfMissing(true) .setCreateIfMissing(true)
.setMaxWriteBufferNumber(3)
.setTableFormatConfig(tableOptions) .setTableFormatConfig(tableOptions)
.setMaxBackgroundCompactions(10)
.setMaxBackgroundCompactions(5)
.setMaxBackgroundFlushes(4) .setMaxBackgroundFlushes(4)
.setBloomLocality(10)
.setMinWriteBufferNumberToMerge(4)
.setCompressionPerLevel(compressionLevels)
.setNumLevels(7)
.setMemTableConfig(new SkipListMemTableConfig()) .setMemTableConfig(new SkipListMemTableConfig())
; ;
return options; return options;


Loading…
Cancel
Save