Skip to content

Commit

Permalink
feat:support result cache, issue: #315
Browse files Browse the repository at this point in the history
  • Loading branch information
tbs60 committed Jan 20, 2025
1 parent 96fe3e9 commit ff38c8f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/backend/booster/bk_dist/common/resultcache/filemgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (f *FileMgrWithARC) load() {
defer f.mutexARC.Unlock()

// filedir / groupkey / hash[0] / hash[1] / hash / files..
// 搜索 filedir 下的所有4层子目录
// 搜索 filedir 下的所有第4层子目录
baselen := getPathDepth(f.filedir)
filepath.Walk(f.filedir, func(path string, info os.FileInfo, err error) error {
if err != nil {
Expand All @@ -90,8 +90,8 @@ func (f *FileMgrWithARC) load() {

if info.IsDir() {
curpathlen := getPathDepth(path)
if curpathlen-baselen == 3 {
dir := filepath.Join(path, info.Name())
if curpathlen-baselen == 4 {
dir := path
if strings.HasSuffix(dir, DeleteFlag) {
blog.Infof("FileMgrWithARC: load %s to delete cache", dir)
f.addDelete(dir)
Expand Down
2 changes: 2 additions & 0 deletions src/backend/booster/bk_dist/worker/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ type WorkerConfig struct {
// slot由worker提供,而不是客户端指定
OfferSlot bool `json:"offer_slot" value:"true" usage:"whether support offer slot"`

// result cache switch
ResultCache bool `json:"result_cache" value:"false" usage:"whether support result cache"`
// result cache dir
ResultCacheDir string `json:"result_cache_dir" value:"" usage:"result cache dir"`
// max result files
Expand Down
6 changes: 6 additions & 0 deletions src/backend/booster/bk_dist/worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"os"
"path/filepath"

"github.com/TencentBlueKing/bk-turbo/src/backend/booster/bk_dist/common/resultcache"
"github.com/TencentBlueKing/bk-turbo/src/backend/booster/bk_dist/worker/config"
"github.com/TencentBlueKing/bk-turbo/src/backend/booster/bk_dist/worker/pkg"
"github.com/TencentBlueKing/bk-turbo/src/backend/booster/common/blog"
Expand All @@ -36,6 +37,11 @@ func main() {
config.GlobalResultCacheDir = c.ResultCacheDir
config.GlobalMaxFileNumber = c.MaxResultFileNumber
config.GlobalMaxIndexNumber = c.MaxResultIndexNumber
if c.ResultCache {
resultcache.GetInstance(config.GlobalResultCacheDir,
config.GlobalMaxFileNumber,
config.GlobalMaxIndexNumber)
}

if !filepath.IsAbs(c.LogConfig.LogDir) {
newabs, err := filepath.Abs(c.LogConfig.LogDir)
Expand Down

0 comments on commit ff38c8f

Please sign in to comment.