attempt to improve rocksdb options

This commit is contained in:
mcrcortex
2025-06-02 22:12:29 +10:00
parent 204989b909
commit 075e8f2897

View File

@@ -54,22 +54,39 @@ public class RocksDBStorageBackend extends StorageBackend {
//TODO: FIXME: DONT USE THE SAME options PER COLUMN FAMILY //TODO: FIXME: DONT USE THE SAME options PER COLUMN FAMILY
final ColumnFamilyOptions cfOpts = new ColumnFamilyOptions() final ColumnFamilyOptions cfOpts = new ColumnFamilyOptions()
.setCompressionType(CompressionType.ZSTD_COMPRESSION)
.optimizeForSmallDb();
final ColumnFamilyOptions cfWorldSecOpts = new ColumnFamilyOptions()
.setCompressionType(CompressionType.NO_COMPRESSION) .setCompressionType(CompressionType.NO_COMPRESSION)
.setCompactionPriority(CompactionPriority.MinOverlappingRatio)
.setLevelCompactionDynamicLevelBytes(true)
.optimizeForPointLookup(128); .optimizeForPointLookup(128);
var bCache = new HyperClockCache(128*1024L*1024L,0, 4, false);
var filter = new BloomFilter(10);
cfWorldSecOpts.setTableFormatConfig(new BlockBasedTableConfig()
.setCacheIndexAndFilterBlocksWithHighPriority(true)
.setBlockCache(bCache)
.setDataBlockHashTableUtilRatio(0.75)
//.setIndexType(IndexType.kHashSearch)//Maybe?
.setDataBlockIndexType(DataBlockIndexType.kDataBlockBinaryAndHash)
.setFilterPolicy(filter)
);
final List<ColumnFamilyDescriptor> cfDescriptors = Arrays.asList( final List<ColumnFamilyDescriptor> cfDescriptors = Arrays.asList(
new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY, cfOpts), new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY, cfOpts),
new ColumnFamilyDescriptor("world_sections".getBytes(), cfOpts), new ColumnFamilyDescriptor("world_sections".getBytes(), cfWorldSecOpts),
new ColumnFamilyDescriptor("id_mappings".getBytes(), cfOpts) new ColumnFamilyDescriptor("id_mappings".getBytes(), cfOpts)
); );
final DBOptions options = new DBOptions() final DBOptions options = new DBOptions()
//.setUnorderedWrite(true)
.setAvoidUnnecessaryBlockingIO(true) .setAvoidUnnecessaryBlockingIO(true)
.setIncreaseParallelism(2) .setIncreaseParallelism(2)
.setCreateIfMissing(true) .setCreateIfMissing(true)
.setCreateMissingColumnFamilies(true) .setCreateMissingColumnFamilies(true)
.setMaxTotalWalSize(1024*1024*512);//512 mb max WAL size .setMaxTotalWalSize(1024*1024*128);//128 mb max WAL size
List<ColumnFamilyHandle> handles = new ArrayList<>(); List<ColumnFamilyHandle> handles = new ArrayList<>();
@@ -85,8 +102,11 @@ public class RocksDBStorageBackend extends StorageBackend {
this.closeList.add(this.db); this.closeList.add(this.db);
this.closeList.add(options); this.closeList.add(options);
this.closeList.add(cfOpts); this.closeList.add(cfOpts);
this.closeList.add(cfWorldSecOpts);
this.closeList.add(this.sectionReadOps); this.closeList.add(this.sectionReadOps);
this.closeList.add(this.sectionWriteOps); this.closeList.add(this.sectionWriteOps);
this.closeList.add(filter);
this.closeList.add(bCache);
this.worldSections = handles.get(1); this.worldSections = handles.get(1);
this.idMappings = handles.get(2); this.idMappings = handles.get(2);
@@ -193,6 +213,7 @@ public class RocksDBStorageBackend extends StorageBackend {
@Override @Override
public void close() { public void close() {
this.flush();
this.closeList.forEach(AbstractImmutableNativeReference::close); this.closeList.forEach(AbstractImmutableNativeReference::close);
} }