frostfs-node/pkg/local_object_storage/writecache/writecachebadger/gc.go
Alejandro Lopez 4d88bdd4e5
All checks were successful
Build / Build Components (1.19) (pull_request) Successful in 2m15s
Tests and linters / Tests (1.19) (pull_request) Successful in 2m22s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m50s
Build / Build Components (1.20) (pull_request) Successful in 12m23s
Tests and linters / Tests with -race (pull_request) Successful in 5m47s
Vulncheck / Vulncheck (pull_request) Successful in 1m6s
Tests and linters / Lint (pull_request) Successful in 14m38s
Tests and linters / Staticcheck (pull_request) Successful in 6m14s
[#421] Try using badger for the write-cache
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
2023-08-02 18:25:53 +03:00

31 lines
607 B
Go

package writecachebadger
import (
"time"
"git.frostfs.info/TrueCloudLab/frostfs-node/internal/logs"
)
func (c *cache) runGCLoop() {
c.wg.Add(1)
go func() {
defer c.wg.Done()
t := time.NewTicker(c.gcInterval)
defer t.Stop()
for {
select {
case <-c.closeCh:
return
case <-t.C:
// 0.5 is the recommended value so that write amplification of the value log is 2.
// See https://pkg.go.dev/github.com/dgraph-io/badger/v4#DB.RunValueLogGC for more info.
for c.db.RunValueLogGC(0.5) == nil {
c.log.Debug(logs.WritecacheDBValueLogGCRunCompleted)
}
}
}
}()
}