mirror of https://github.com/milvus-io/milvus.git
enable config shard level cost metrics whether contains worker's cost (#26132)
Signed-off-by: Wei Liu <wei.liu@zilliz.com>pull/26232/head
parent
2770ac4df5
commit
f33a89387f
|
@ -32,6 +32,7 @@ import (
|
|||
typeutil2 "github.com/milvus-io/milvus/internal/util/typeutil"
|
||||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/log"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
||||
)
|
||||
|
||||
|
@ -75,8 +76,16 @@ func ReduceSearchResults(ctx context.Context, results []*internalpb.SearchResult
|
|||
return nil, err
|
||||
}
|
||||
|
||||
requestCosts := lo.Map(results, func(result *internalpb.SearchResults, _ int) *internalpb.CostAggregation {
|
||||
return result.GetCostAggregation()
|
||||
requestCosts := lo.FilterMap(results, func(result *internalpb.SearchResults, _ int) (*internalpb.CostAggregation, bool) {
|
||||
if paramtable.Get().QueryNodeCfg.EnableWorkerSQCostMetrics.GetAsBool() {
|
||||
return result.GetCostAggregation(), true
|
||||
}
|
||||
|
||||
if result.GetBase().GetSourceID() == paramtable.GetNodeID() {
|
||||
return result.GetCostAggregation(), true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
})
|
||||
searchResults.CostAggregation = mergeRequestCost(requestCosts)
|
||||
|
||||
|
@ -289,10 +298,15 @@ func MergeInternalRetrieveResult(ctx context.Context, retrieveResults []*interna
|
|||
}
|
||||
|
||||
requestCosts := lo.FilterMap(retrieveResults, func(result *internalpb.RetrieveResults, _ int) (*internalpb.CostAggregation, bool) {
|
||||
if result.CostAggregation == nil {
|
||||
return nil, false
|
||||
if paramtable.Get().QueryNodeCfg.EnableWorkerSQCostMetrics.GetAsBool() {
|
||||
return result.GetCostAggregation(), true
|
||||
}
|
||||
return result.CostAggregation, true
|
||||
|
||||
if result.GetBase().GetSourceID() == paramtable.GetNodeID() {
|
||||
return result.GetCostAggregation(), true
|
||||
}
|
||||
|
||||
return nil, false
|
||||
})
|
||||
ret.CostAggregation = mergeRequestCost(requestCosts)
|
||||
|
||||
|
|
|
@ -123,6 +123,9 @@ func (t *QueryTask) Execute() error {
|
|||
}
|
||||
|
||||
t.result = &internalpb.RetrieveResults{
|
||||
Base: &commonpb.MsgBase{
|
||||
SourceID: paramtable.GetNodeID(),
|
||||
},
|
||||
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
||||
Ids: reducedResult.Ids,
|
||||
FieldsData: reducedResult.FieldsData,
|
||||
|
|
|
@ -159,6 +159,9 @@ func (t *SearchTask) Execute() error {
|
|||
}
|
||||
|
||||
task.result = &internalpb.SearchResults{
|
||||
Base: &commonpb.MsgBase{
|
||||
SourceID: paramtable.GetNodeID(),
|
||||
},
|
||||
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
||||
MetricType: req.GetReq().GetMetricType(),
|
||||
NumQueries: t.originNqs[i],
|
||||
|
@ -212,6 +215,9 @@ func (t *SearchTask) Execute() error {
|
|||
Observe(float64(reduceLatency.Milliseconds()))
|
||||
|
||||
task.result = &internalpb.SearchResults{
|
||||
Base: &commonpb.MsgBase{
|
||||
SourceID: paramtable.GetNodeID(),
|
||||
},
|
||||
Status: util.WrapStatus(commonpb.ErrorCode_Success, ""),
|
||||
MetricType: req.GetReq().GetMetricType(),
|
||||
NumQueries: t.originNqs[i],
|
||||
|
|
|
@ -1563,6 +1563,8 @@ type queryNodeConfig struct {
|
|||
|
||||
// CGOPoolSize ratio to MaxReadConcurrency
|
||||
CGOPoolSizeRatio ParamItem `refreshable:"false"`
|
||||
|
||||
EnableWorkerSQCostMetrics ParamItem `refreshable:"true"`
|
||||
}
|
||||
|
||||
func (p *queryNodeConfig) init(base *BaseTable) {
|
||||
|
@ -1925,6 +1927,14 @@ Max read concurrency must greater than or equal to 1, and less than or equal to
|
|||
Doc: "cgo pool size ratio to max read concurrency",
|
||||
}
|
||||
p.CGOPoolSizeRatio.Init(base.mgr)
|
||||
|
||||
p.EnableWorkerSQCostMetrics = ParamItem{
|
||||
Key: "queryNode.enableWorkerSQCostMetrics",
|
||||
Version: "2.3.0",
|
||||
DefaultValue: "false",
|
||||
Doc: "whether use worker's cost to measure delegator's workload",
|
||||
}
|
||||
p.EnableWorkerSQCostMetrics.Init(base.mgr)
|
||||
}
|
||||
|
||||
// /////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -339,6 +339,8 @@ func TestComponentParam(t *testing.T) {
|
|||
params.Save("queryNode.gracefulStopTimeout", "100")
|
||||
gracefulStopTimeout := Params.GracefulStopTimeout
|
||||
assert.Equal(t, int64(100), gracefulStopTimeout.GetAsInt64())
|
||||
|
||||
assert.Equal(t, false, Params.EnableWorkerSQCostMetrics.GetAsBool())
|
||||
})
|
||||
|
||||
t.Run("test dataCoordConfig", func(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue