Skip to content

Commit

Permalink
feat:support result cache, issue: TencentBlueKing#315
Browse files Browse the repository at this point in the history
  • Loading branch information
tbs60 committed Jan 8, 2025
1 parent 867baba commit d4dcc1c
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 125 deletions.
255 changes: 136 additions & 119 deletions src/backend/booster/bk_dist/common/protocol/task_worker.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/backend/booster/bk_dist/common/protocol/task_worker.proto
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ message PBBodyQueryResultCacheIndexReq {

message PBBodyQueryResultCacheIndexRsp {
optional bytes list = 1; // 列表,可以为空
optional PBCompressType compresstype = 2;
optional int32 originlength = 3;
}

message PBBodyQueryResultCacheFileReq {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,3 @@ func (m *Mgr) reportRemoteResultCache(

return nil, nil
}

func (m *Mgr) getCacheList() {
// m.work.Resource().
}
1 change: 1 addition & 0 deletions src/backend/booster/bk_dist/ubttool/pkg/ubttool.go
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ func (h *UBTTool) newBooster() (*pkg.Booster, error) {
MaxLocalPreJobs: h.settings.MaxLocalPreJobs,
MaxLocalExeJobs: h.settings.MaxLocalExeJobs,
MaxLocalPostJobs: h.settings.MaxLocalPostJobs,
ResultCacheList: h.settings.ResultCacheList,
},

Transport: dcType.BoosterTransport{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,18 @@ func decodeQueryCacheIndexRsp(
}

if r != nil {
result.ResultIndex = r.List
data := r.List
if *r.Compresstype == protocol.PBCompressType_LZ4 && len(r.List) > 0 && *r.Originlength > 0 {
dst := make([]byte, *r.Originlength)
outdata, err := dcUtil.Lz4Uncompress(data, dst)
if err == nil {
data = outdata
} else {
blog.Warnf("failed to uncompress result cache index data: %v", err)
return nil, err
}
}
result.ResultIndex = data
}

return &result, nil
Expand Down
11 changes: 10 additions & 1 deletion src/backend/booster/bk_dist/worker/pkg/protocol/pb_protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -1467,8 +1467,17 @@ func EncodeBKQueryResultCacheIndexRsp(
var filebuflen int64

// encode body and file to message
originlength := int32(len(data))
compresseddata := data
compresstype := protocol.PBCompressType_NONE
if originlength > 0 {
compresseddata, _ = dcUtil.Lz4Compress(data)
compresstype = protocol.PBCompressType_LZ4
}
pbbody := protocol.PBBodyQueryResultCacheIndexRsp{
List: data,
List: compresseddata,
Compresstype: &compresstype,
Originlength: &originlength,
}

bodydata, err := proto.Marshal(&pbbody)
Expand Down

0 comments on commit d4dcc1c

Please sign in to comment.