mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
enhance: [2.5] improve sparse query nnz metric (#40714)
add query type and field id label; add metric for hybrid search issue: https://github.com/milvus-io/milvus/issues/35853 pr: https://github.com/milvus-io/milvus/pull/40713 Signed-off-by: Buqian Zheng <zhengbuqian@gmail.com>
This commit is contained in:
parent
281260e48a
commit
cff0e82f57
@ -414,6 +414,9 @@ func (t *searchTask) initAdvancedSearchRequest(ctx context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if typeutil.IsFieldSparseFloatVector(t.schema.CollectionSchema, internalSubReq.FieldId) {
|
||||||
|
metrics.ProxySearchSparseNumNonZeros.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), t.collectionName, metrics.HybridSearchLabel, strconv.FormatInt(internalSubReq.FieldId, 10)).Observe(float64(typeutil.EstimateSparseVectorNNZFromPlaceholderGroup(internalSubReq.PlaceholderGroup, int(internalSubReq.GetNq()))))
|
||||||
|
}
|
||||||
t.SearchRequest.SubReqs[index] = internalSubReq
|
t.SearchRequest.SubReqs[index] = internalSubReq
|
||||||
t.queryInfos[index] = queryInfo
|
t.queryInfos[index] = queryInfo
|
||||||
log.Debug("proxy init search request",
|
log.Debug("proxy init search request",
|
||||||
@ -491,7 +494,9 @@ func (t *searchTask) initSearchRequest(ctx context.Context) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
metrics.ProxySearchSparseNumNonZeros.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), t.collectionName).Observe(float64(typeutil.EstimateSparseVectorNNZFromPlaceholderGroup(t.request.PlaceholderGroup, int(t.request.GetNq()))))
|
if typeutil.IsFieldSparseFloatVector(t.schema.CollectionSchema, t.SearchRequest.FieldId) {
|
||||||
|
metrics.ProxySearchSparseNumNonZeros.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), t.collectionName, metrics.SearchLabel, strconv.FormatInt(t.SearchRequest.FieldId, 10)).Observe(float64(typeutil.EstimateSparseVectorNNZFromPlaceholderGroup(t.request.PlaceholderGroup, int(t.request.GetNq()))))
|
||||||
|
}
|
||||||
t.SearchRequest.PlaceholderGroup = t.request.PlaceholderGroup
|
t.SearchRequest.PlaceholderGroup = t.request.PlaceholderGroup
|
||||||
t.SearchRequest.Topk = queryInfo.GetTopk()
|
t.SearchRequest.Topk = queryInfo.GetTopk()
|
||||||
t.SearchRequest.MetricType = queryInfo.GetMetricType()
|
t.SearchRequest.MetricType = queryInfo.GetMetricType()
|
||||||
|
|||||||
@ -1030,7 +1030,7 @@ func (sd *shardDelegator) buildBM25IDF(req *internalpb.SearchRequest) (float64,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, idf := range idfSparseVector {
|
for _, idf := range idfSparseVector {
|
||||||
metrics.QueryNodeSearchFTSNumTokens.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), fmt.Sprint(sd.collectionID)).Observe(float64(typeutil.SparseFloatRowElementCount(idf)))
|
metrics.QueryNodeSearchFTSNumTokens.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), fmt.Sprint(sd.collectionID), fmt.Sprint(req.GetFieldId())).Observe(float64(typeutil.SparseFloatRowElementCount(idf)))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = SetBM25Params(req, avgdl)
|
err = SetBM25Params(req, avgdl)
|
||||||
|
|||||||
@ -94,6 +94,7 @@ const (
|
|||||||
indexTaskStatusLabelName = "index_task_status"
|
indexTaskStatusLabelName = "index_task_status"
|
||||||
msgTypeLabelName = "msg_type"
|
msgTypeLabelName = "msg_type"
|
||||||
collectionIDLabelName = "collection_id"
|
collectionIDLabelName = "collection_id"
|
||||||
|
fieldIDLabelName = "field_id"
|
||||||
channelNameLabelName = "channel_name"
|
channelNameLabelName = "channel_name"
|
||||||
functionLabelName = "function_name"
|
functionLabelName = "function_name"
|
||||||
queryTypeLabelName = "query_type"
|
queryTypeLabelName = "query_type"
|
||||||
|
|||||||
@ -426,7 +426,7 @@ var (
|
|||||||
Name: "search_sparse_num_non_zeros",
|
Name: "search_sparse_num_non_zeros",
|
||||||
Help: "the number of non-zeros in each sparse search task",
|
Help: "the number of non-zeros in each sparse search task",
|
||||||
Buckets: buckets,
|
Buckets: buckets,
|
||||||
}, []string{nodeIDLabelName, collectionName})
|
}, []string{nodeIDLabelName, collectionName, queryTypeLabelName, fieldIDLabelName})
|
||||||
|
|
||||||
ProxyParseExpressionLatency = prometheus.NewHistogramVec(
|
ProxyParseExpressionLatency = prometheus.NewHistogramVec(
|
||||||
prometheus.HistogramOpts{
|
prometheus.HistogramOpts{
|
||||||
|
|||||||
@ -360,6 +360,7 @@ var (
|
|||||||
}, []string{
|
}, []string{
|
||||||
nodeIDLabelName,
|
nodeIDLabelName,
|
||||||
collectionIDLabelName,
|
collectionIDLabelName,
|
||||||
|
fieldIDLabelName,
|
||||||
})
|
})
|
||||||
|
|
||||||
QueryNodeSearchGroupSize = prometheus.NewHistogramVec(
|
QueryNodeSearchGroupSize = prometheus.NewHistogramVec(
|
||||||
|
|||||||
@ -1183,6 +1183,11 @@ func GetPrimaryFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSc
|
|||||||
return nil, errors.New("primary field is not found")
|
return nil, errors.New("primary field is not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsFieldSparseFloatVector(schema *schemapb.CollectionSchema, fieldID int64) bool {
|
||||||
|
fieldSchema := GetField(schema, fieldID)
|
||||||
|
return fieldSchema != nil && IsSparseFloatVectorType(fieldSchema.DataType)
|
||||||
|
}
|
||||||
|
|
||||||
// GetPartitionKeyFieldSchema get partition field schema from collection schema
|
// GetPartitionKeyFieldSchema get partition field schema from collection schema
|
||||||
func GetPartitionKeyFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
func GetPartitionKeyFieldSchema(schema *schemapb.CollectionSchema) (*schemapb.FieldSchema, error) {
|
||||||
for _, fieldSchema := range schema.GetFields() {
|
for _, fieldSchema := range schema.GetFields() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user