Skip to content

Commit

Permalink
modify options of autocompact and diskio
Browse files Browse the repository at this point in the history
  • Loading branch information
yanxiaoqi932 committed Jan 8, 2025
1 parent c44aabf commit 18fafd6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 10 additions & 4 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ func Open(options Options) (*DB, error) {

// start disk IO monitoring,
// blocking low threshold compact operations when busy.
go db.listenDiskIOState()
if options.EnableDiskIO {
go db.listenDiskIOState()
}
}

return db, nil
Expand Down Expand Up @@ -608,9 +610,13 @@ func (db *DB) listenAutoCompact() {
thresholdstate = ThresholdState(UnarriveThreshold)
} else if thresholdstate == ThresholdState(ArriveAdvisedThreshold) {
// determine whether to do compact based on the current IO state
free, err := db.diskIO.IsFree()
if err != nil {
panic(err)
free := true
var err error = nil

Check warning on line 614 in db.go

View workflow job for this annotation

GitHub Actions / windows-test

var-declaration: should drop = nil from declaration of var err; it is the zero value (revive)

Check warning on line 614 in db.go

View workflow job for this annotation

GitHub Actions / ubuntu-test

var-declaration: should drop = nil from declaration of var err; it is the zero value (revive)
if db.options.EnableDiskIO {
free, err = db.diskIO.IsFree()
if err != nil {
panic(err)
}
}
if free {
if firstCompact {
Expand Down
7 changes: 6 additions & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ type Options struct {
// deprecatedtable force compaction rate
ForceCompactionRate float32

// whether enable disk monitor
EnableDiskIO bool

// sampling interval of diskIO, unit is millisecond
DiskIOSamplingInterval int

Expand Down Expand Up @@ -146,12 +149,14 @@ var DefaultOptions = Options{
//nolint:gomnd // default
ForceCompactionRate: 0.5,
//nolint:gomnd // default
EnableDiskIO: false,
//nolint:gomnd // default
DiskIOSamplingInterval: 100,
//nolint:gomnd // default
DiskIOSamplingWindow: 10,
//nolint:gomnd // default
DiskIOBusyRate: 0.5,
AutoCompactSupport: true,
AutoCompactSupport: false,
//nolint:gomnd // default
WaitMemSpaceTimeout: 100 * time.Millisecond,
}
Expand Down

0 comments on commit 18fafd6

Please sign in to comment.