Exposed more badger options for memory utilization tweaks (#107)

* GC Fix

* Addressed all comments and added unit test

Fixed the replay use case and added unit test

* Removed the GetMin and GetMaxPartitions functions as they are not required now

* Added more unit test cases

* Badger Tweaks for memory utilization
This commit is contained in:
sana-jawad 2020-02-19 14:57:22 -08:00 коммит произвёл GitHub
Родитель e0a8d06841
Коммит 7d94723dfa
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -162,7 +162,6 @@ func Test_EventCountTable_Events_Added_After_TruncateTS(t *testing.T) {
// adding the first event which ends up adding the first partition
addEventCount(t, tables, eventPTime28August, timestamp28AugustStartTime, timestamp28AugustEndTime)
timestamp29AugustStartTime := "2019-08-29T21:24:55Z"
timestamp29AugustEndTime := "2019-08-29T23:27:55Z"
eventPTime29August, _ := ptypes.TimestampProto(time.Date(2019, 8, 29, 21, 24, 55, 6, time.UTC))

Просмотреть файл

@ -60,6 +60,10 @@ type SloopConfig struct {
BadgerVLogMaxEntries uint `json:"badgerVLogMaxEntries"`
BadgerUseLSMOnlyOptions bool `json:"badgerUseLSMOnlyOptions"`
BadgerEnableEventLogging bool `json:"badgerEnableEventLogging"`
BadgerNumOfCompactors int `json:"badgerNumOfCompactors"`
BadgerNumL0Tables int `json:"badgerNumLevelZeroTables"`
BadgerNumL0TablesStall int `json:"badgerNumLevelZeroTables"`
BadgerSyncWrites bool `json:"badgerBadgerSyncWrites"`
}
func registerFlags(fs *flag.FlagSet, config *SloopConfig) {
@ -95,6 +99,10 @@ func registerFlags(fs *flag.FlagSet, config *SloopConfig) {
fs.UintVar(&config.BadgerVLogMaxEntries, "badger-vlog-max-entries", 0, "Max number of entries per value log files. 0 = use badger default")
fs.BoolVar(&config.BadgerUseLSMOnlyOptions, "badger-use-lsm-only-options", true, "Sets a higher valueThreshold so values would be collocated with LSM tree reducing vlog disk usage")
fs.BoolVar(&config.BadgerEnableEventLogging, "badger-enable-event-logging", false, "Turns on badger event logging")
fs.IntVar(&config.BadgerNumOfCompactors, "badger-number-of-compactors", 0, "Number of compactors for badger")
fs.IntVar(&config.BadgerNumL0Tables, "badger-number-of-level-zero-tables", 0, "Number of level zero tables for badger")
fs.IntVar(&config.BadgerNumL0TablesStall, "badger-number-of-zero-tables-stall", 0, "Number of Level 0 tables that once reached causes the DB to stall until compaction succeeds")
fs.BoolVar(&config.BadgerSyncWrites, "badger-sync-writes", true, "Sync Writes ensures writes are synced to disk if set to true")
}
// This will first check if a config file is specified on cmd line using a temporary flagSet

Просмотреть файл

@ -66,6 +66,10 @@ func RealMain() error {
BadgerVLogMaxEntries: conf.BadgerVLogMaxEntries,
BadgerUseLSMOnlyOptions: conf.BadgerUseLSMOnlyOptions,
BadgerEnableEventLogging: conf.BadgerEnableEventLogging,
BadgerNumOfCompactors: conf.BadgerNumOfCompactors,
BadgerNumL0Tables: conf.BadgerNumL0Tables,
BadgerNumL0TablesStall: conf.BadgerNumL0TablesStall,
BadgerSyncWrites: conf.BadgerSyncWrites,
}
db, err := untyped.OpenStore(factory, storeConfig)
if err != nil {

Просмотреть файл

@ -25,6 +25,10 @@ type Config struct {
BadgerVLogMaxEntries uint
BadgerUseLSMOnlyOptions bool
BadgerEnableEventLogging bool
BadgerNumOfCompactors int
BadgerNumL0Tables int
BadgerNumL0TablesStall int
BadgerSyncWrites bool
}
func OpenStore(factory badgerwrap.Factory, config *Config) (badgerwrap.DB, error) {
@ -60,6 +64,19 @@ func OpenStore(factory badgerwrap.Factory, config *Config) (badgerwrap.DB, error
opts = opts.WithValueLogMaxEntries(uint32(config.BadgerVLogMaxEntries))
}
if config.BadgerNumOfCompactors != 0 {
opts = opts.WithNumCompactors(config.BadgerNumOfCompactors)
}
if config.BadgerNumL0Tables != 0 {
opts = opts.WithNumLevelZeroTables(config.BadgerNumL0Tables)
}
if config.BadgerNumL0TablesStall != 0 {
opts = opts.WithNumLevelZeroTablesStall(config.BadgerNumL0TablesStall)
}
opts.WithSyncWrites(config.BadgerSyncWrites)
db, err := factory.Open(opts)
if err != nil {
return nil, fmt.Errorf("badger.OpenStore failed with: %v", err)