diff --git a/db.go b/db.go index 8a5ef78..c5a028d 100644 --- a/db.go +++ b/db.go @@ -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 @@ -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 + if db.options.EnableDiskIO { + free, err = db.diskIO.IsFree() + if err != nil { + panic(err) + } } if free { if firstCompact { diff --git a/options.go b/options.go index c548252..274a4ff 100644 --- a/options.go +++ b/options.go @@ -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 @@ -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, }