milvus-io / milvus

A cloud-native vector database, storage for next generation AI applications
https://milvus.io
Apache License 2.0
27.28k stars 2.63k forks source link

[Enhancement]: local reduce can be optimized if only one segment is involved #32728

Open longjiquan opened 3 weeks ago

longjiquan commented 3 weeks ago

Is there an existing issue for this?

What would you like to be added?

https://github.com/milvus-io/milvus/blob/77f4f0c5a82f71c148a10e4719df48033dfd4d6c/internal/core/src/segcore/Reduce.cpp#L222-L311

Why is this needed?

9PfCtXlffP

If only one segment was involved in the reduce phase, in fact we waste the cpu of heap-sort to complete the reduce. We can do it more simply.

Anything else?

No response

longjiquan commented 3 weeks ago

the tracing can be found in https://github.com/milvus-io/milvus/pull/32734

xiaofan-luan commented 2 weeks ago

seems to be a promising optimization