Skip to content

Commit

Permalink
Merge pull request #41 from youzan/improve-raft-perf
Browse files Browse the repository at this point in the history
Improve rocksdb options
  • Loading branch information
absolute8511 authored Aug 14, 2019
2 parents 5afca0c + 5494689 commit c30943a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 2 deletions.
16 changes: 14 additions & 2 deletions engine/rockeng.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type RockOptions struct {
BlockSize int `json:"block_size"`
BlockCache int64 `json:"block_cache"`
CacheIndexAndFilterBlocks bool `json:"cache_index_and_filter_blocks"`
EnablePartitionedIndexFilter bool `json:"enable_partitioned_index_filter"`
WriteBufferSize int `json:"write_buffer_size"`
MaxWriteBufferNumber int `json:"max_write_buffer_number"`
MinWriteBufferNumberToMerge int `json:"min_write_buffer_number_to_merge"`
Expand Down Expand Up @@ -117,7 +118,7 @@ func FillDefaultOptions(opts *RockOptions) {
opts.BackgroundHighThread = 2
}
if opts.BackgroundLowThread <= 0 {
opts.BackgroundLowThread = 8
opts.BackgroundLowThread = 16
}
}
}
Expand Down Expand Up @@ -163,7 +164,7 @@ func NewSharedRockConfig(opt RockOptions) *SharedRockConfig {
opt.BackgroundHighThread = 2
}
if opt.BackgroundLowThread <= 0 {
opt.BackgroundLowThread = 8
opt.BackgroundLowThread = 16
}
rc.SharedEnv.SetBackgroundThreads(opt.BackgroundLowThread)
rc.SharedEnv.SetHighPriorityBackgroundThreads(opt.BackgroundHighThread)
Expand Down Expand Up @@ -232,6 +233,17 @@ func NewRockEng(cfg *RockEngConfig) (*RockEng, error) {
// and see this https://github.com/facebook/rocksdb/pull/3692 if partitioned filter is on
bbto.SetPinL0FilterAndIndexBlocksInCache(true)

if cfg.EnablePartitionedIndexFilter {
//enable partitioned indexes and partitioned filters
bbto.SetCacheIndexAndFilterBlocksWithHighPriority(true)
bbto.SetIndexType(gorocksdb.IndexTypeTwoLevelIndexSearch)
bbto.SetPartitionFilters(true)
bbto.SetMetaDataBlockSize(1024 * 8)
bbto.SetCacheIndexAndFilterBlocks(true)
}
bbto.SetFormatVersion(4)
bbto.SetIndexBlockRestartInterval(16)

// /* filter should not block_based, use sst based to reduce cpu */
filter := gorocksdb.NewBloomFilter(10, false)
bbto.SetFilterPolicy(filter)
Expand Down
3 changes: 3 additions & 0 deletions rockredis/rockredis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
func getTestDBNoTableCounter(t *testing.T) *RockDB {
cfg := NewRockRedisDBConfig()
cfg.EnableTableCounter = false
cfg.EnablePartitionedIndexFilter = true
var err error
cfg.DataDir, err = ioutil.TempDir("", fmt.Sprintf("rockredis-test-%d", time.Now().UnixNano()))
assert.Nil(t, err)
Expand All @@ -29,6 +30,7 @@ func getTestDBWithDir(t *testing.T, dataDir string) *RockDB {
cfg := NewRockRedisDBConfig()
cfg.EnableTableCounter = true
cfg.DataDir = dataDir
cfg.EnablePartitionedIndexFilter = true
testDB, err := OpenRockDB(cfg)
assert.Nil(t, err)
if testing.Verbose() {
Expand All @@ -40,6 +42,7 @@ func getTestDBWithDir(t *testing.T, dataDir string) *RockDB {
func getTestDB(t *testing.T) *RockDB {
cfg := NewRockRedisDBConfig()
cfg.EnableTableCounter = true
cfg.EnablePartitionedIndexFilter = true
var err error
cfg.DataDir, err = ioutil.TempDir("", fmt.Sprintf("rockredis-test-%d", time.Now().UnixNano()))
assert.Nil(t, err)
Expand Down
1 change: 1 addition & 0 deletions server/redis_api_fullscan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func startFullScanTestServer(t *testing.T) (*Server, int, string) {
UseRocksWAL: true,
SharedRocksWAL: true,
}
kvOpts.RocksDBOpts.EnablePartitionedIndexFilter = true
nsConf := node.NewNSConfig()
nsConf.Name = "default-0"
nsConf.BaseName = "default"
Expand Down
1 change: 1 addition & 0 deletions server/redis_api_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func startMergeTestServer(t *testing.T) (*Server, int, string) {
TickMs: 100,
ElectionTick: 5,
}
kvOpts.RocksDBOpts.EnablePartitionedIndexFilter = true
kv := NewServer(kvOpts)
var replica node.ReplicaInfo
replica.NodeID = 1
Expand Down
1 change: 1 addition & 0 deletions server/redis_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func startTestServer(t *testing.T, port int) (*Server, int, string) {
UseRocksWAL: true,
SharedRocksWAL: true,
}
kvOpts.RocksDBOpts.EnablePartitionedIndexFilter = true

nsConf := node.NewNSConfig()
nsConf.Name = "default-0"
Expand Down
1 change: 1 addition & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func startTestClusterWithBasePort(t *testing.T, portBase int, replicaNum int, sy
UseRocksWAL: true,
SharedRocksWAL: true,
}
kvOpts.RocksDBOpts.EnablePartitionedIndexFilter = true
if index >= replicaNum {
kvOpts.LearnerRole = common.LearnerRoleLogSyncer
// use test:// will ignore the remote cluster fail
Expand Down

0 comments on commit c30943a

Please sign in to comment.