Skip to content

Commit

Permalink
Enable caching filter and indexes in block cache
Browse files Browse the repository at this point in the history
  • Loading branch information
aalda committed Apr 3, 2019
1 parent d44935d commit 9de65e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions raftwal/raftrocks/rocksdb_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ func New(options Options) (*RocksDBStore, error) {
// log store options
logBbto := rocksdb.NewDefaultBlockBasedTableOptions()
logBbto.SetBlockSize(32 * 1024)
logBbto.SetCacheIndexAndFilterBlocks(true)
logCache := rocksdb.NewDefaultLRUCache(512 * 1024 * 1024)
logBbto.SetBlockCache(logCache)
logOpts := rocksdb.NewDefaultOptions()
Expand Down
7 changes: 6 additions & 1 deletion storage/rocks/rocksdb_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func NewRocksDBStoreOpts(opts *Options) (*RocksDBStore, error) {
globalOpts.SetCreateIfMissingColumnFamilies(true)
//globalOpts.SetMaxOpenFiles()
globalOpts.SetEnv(env)
blockCache := rocksdb.NewDefaultLRUCache(6 * 1024 * 1024 * 1024) // 6GB
blockCache := rocksdb.NewLRUCache(6*1024*1024*1024, 0.4) // 6GB
var stats *rocksdb.Statistics
if opts.EnableStatistics {
stats = rocksdb.NewStatistics()
Expand Down Expand Up @@ -151,6 +151,9 @@ func getHyperCacheTableOpts(blockCache *rocksdb.Cache) *rocksdb.Options {

bbto := rocksdb.NewDefaultBlockBasedTableOptions()
bbto.SetFilterPolicy(rocksdb.NewBloomFilterPolicy(10))
bbto.SetCacheIndexAndFilterBlocks(true)
bbto.SetPinL0FilterAndIndexBlocksInCache(true)
bbto.SetCacheIndexAndFilterBlocksWithHighPriority(true)
bbto.SetBlockCache(blockCache)
// increase block size to 16KB
bbto.SetBlockSize(16 * 1024)
Expand Down Expand Up @@ -202,6 +205,7 @@ func getHistoryCacheTableOpts(blockCache *rocksdb.Cache) *rocksdb.Options {

bbto := rocksdb.NewDefaultBlockBasedTableOptions()
bbto.SetFilterPolicy(rocksdb.NewBloomFilterPolicy(10)) // TODO consider full filters instead of block filters
bbto.SetCacheIndexAndFilterBlocks(true)
bbto.SetBlockCache(blockCache)
// increase block size to 16KB
bbto.SetBlockSize(16 * 1024)
Expand Down Expand Up @@ -257,6 +261,7 @@ func getFsmStateTableOpts() *rocksdb.Options {
// space amplification by keeping a lower number of levels.

bbto := rocksdb.NewDefaultBlockBasedTableOptions()
bbto.SetCacheIndexAndFilterBlocks(true)
// decrease block size to 1KB
bbto.SetBlockSize(1024)

Expand Down

0 comments on commit 9de65e2

Please sign in to comment.