Browse Source

add print of rocksdb2

tags/1.1.10
shaozhuguang 5 years ago
parent
commit
24e2f2574a
2 changed files with 26 additions and 26 deletions
  1. +5
    -0
      source/sdk/sdk-samples/pom.xml
  2. +21
    -26
      source/storage/storage-rocksdb/src/main/java/com/jd/blockchain/storage/service/impl/rocksdb/RocksDBConnectionFactory.java

+ 5
- 0
source/sdk/sdk-samples/pom.xml View File

@@ -30,6 +30,11 @@
<artifactId>contract-samples</artifactId> <artifactId>contract-samples</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcpkix-jdk15on</artifactId>
<version>1.61</version>
</dependency>
</dependencies> </dependencies>


<build> <build>


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

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





Cache cache = new LRUCache(cacheCapacity, cacheNumShardBits, false);
final BlockBasedTableConfig tableOptions = new BlockBasedTableConfig()
.setBlockCache(cache)
.setBlockSize(tableBlockSize)
.setMetadataBlockSize(tableMetadataBlockSize)
.setCacheIndexAndFilterBlocks(true) // 设置索引和布隆过滤器使用Block Cache内存
.setCacheIndexAndFilterBlocksWithHighPriority(true)
.setIndexType(IndexType.kTwoLevelIndexSearch) // 设置两级索引,控制索引占用内存
.setFilterPolicy(new BloomFilter(tableBloomBitsPerKey, false)) // 设置布隆过滤器
;
Options options = new Options()
// 最多占用256 * 7 + 512 = 2G+内存
.setWriteBufferSize(optionWriteBufferSize)
.setMaxWriteBufferNumber(optionMaxWriteBufferNumber)
.setMinWriteBufferNumberToMerge(optionMinWriteBufferNumberToMerge)
.setMaxOpenFiles(optionMaxOpenFiles) // 控制最大打开文件数量,防止内存持续增加
.setAllowConcurrentMemtableWrite(true) //允许并行Memtable写入
.setCreateIfMissing(true)
.setTableFormatConfig(tableOptions)
.setMaxBackgroundCompactions(optionMaxBackgroundCompactions)
.setMaxBackgroundFlushes(optionMaxBackgroundFlushes)
;
return options;
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;
} }


/** /**


Loading…
Cancel
Save