未验证 提交 e6c384b4 编写于 作者: C Cai Yudong 提交者: GitHub

Move segcore chunk_size configuration to querynode.yaml (#7913)

Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 001cb74f
...@@ -25,3 +25,6 @@ queryNode: ...@@ -25,3 +25,6 @@ queryNode:
searchResult: searchResult:
recvBufSize: 64 recvBufSize: 64
segcore:
chunkSize: 32768 # 32M
\ No newline at end of file
# Copyright (C) 2019-2020 Zilliz. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software distributed under the License
# is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
# or implied. See the License for the specific language governing permissions and limitations under the License.
segcore:
chunk_size: 32768 # 32M
...@@ -24,7 +24,7 @@ class KnowhereConfig { ...@@ -24,7 +24,7 @@ class KnowhereConfig {
* set SIMD type * set SIMD type
*/ */
enum SimdType { enum SimdType {
AUTO = 1, // enable all and depend on the system AUTO = 0, // enable all and depend on the system
SSE, // only enable SSE SSE, // only enable SSE
AVX2, // only enable AVX2 AVX2, // only enable AVX2
AVX512, // only enable AVX512 AVX512, // only enable AVX512
......
...@@ -70,7 +70,7 @@ class SegcoreConfig { ...@@ -70,7 +70,7 @@ class SegcoreConfig {
} }
private: private:
int64_t size_per_chunk_ = 32768; int64_t size_per_chunk_ = 32 * 1024;
std::map<MetricType, SmallIndexConf> table_; std::map<MetricType, SmallIndexConf> table_;
}; };
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
namespace milvus::segcore { namespace milvus::segcore {
static void static void
SegcoreInitImpl(const char* config_dir) { SegcoreInitImpl() {
namespace eg = milvus::engine; namespace eg = milvus::engine;
eg::KnowhereConfig::SetSimdType(eg::KnowhereConfig::SimdType::AUTO); eg::KnowhereConfig::SetSimdType(eg::KnowhereConfig::SimdType::AUTO);
eg::KnowhereConfig::SetBlasThreshold(16384); eg::KnowhereConfig::SetBlasThreshold(16384);
...@@ -28,23 +28,17 @@ SegcoreInitImpl(const char* config_dir) { ...@@ -28,23 +28,17 @@ SegcoreInitImpl(const char* config_dir) {
eg::KnowhereConfig::SetStatisticsLevel(0); eg::KnowhereConfig::SetStatisticsLevel(0);
el::Configurations el_conf; el::Configurations el_conf;
el_conf.setGlobally(el::ConfigurationType::Enabled, std::to_string(false)); el_conf.setGlobally(el::ConfigurationType::Enabled, std::to_string(false));
// initializing segcore config
try {
SegcoreConfig& config = SegcoreConfig::default_config();
if (config_dir != NULL) {
std::string config_file = std::string(config_dir) + "advanced/segcore.yaml";
config.parse_from(config_file);
std::cout << "Parse config file: " << config_file << ", chunk_size: " << config.get_size_per_chunk()
<< std::endl;
}
} catch (std::exception& e) {
PanicInfo("parse config fail: " + std::string(e.what()));
}
} }
} // namespace milvus::segcore } // namespace milvus::segcore
extern "C" void extern "C" void
SegcoreInit(const char* config_dir) { SegcoreInit() {
milvus::segcore::SegcoreInitImpl(config_dir); milvus::segcore::SegcoreInitImpl();
}
extern "C" void
SegcoreSetChunkSize(const int64_t value) {
milvus::segcore::SegcoreConfig& config = milvus::segcore::SegcoreConfig::default_config();
config.set_size_per_chunk(value);
std::cout << "set config chunk_size: " << config.get_size_per_chunk() << std::endl;
} }
...@@ -16,7 +16,10 @@ extern "C" { ...@@ -16,7 +16,10 @@ extern "C" {
#endif #endif
void void
SegcoreInit(const char* config_dir); SegcoreInit();
void
SegcoreSetChunkSize(const int64_t);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -19,5 +19,6 @@ ...@@ -19,5 +19,6 @@
TEST(Init, Naive) { TEST(Init, Naive) {
using namespace milvus; using namespace milvus;
using namespace milvus::segcore; using namespace milvus::segcore;
SegcoreInit(NULL); SegcoreInit();
SegcoreSetChunkSize(32768);
} }
\ No newline at end of file
...@@ -68,6 +68,9 @@ type ParamTable struct { ...@@ -68,6 +68,9 @@ type ParamTable struct {
MsgChannelSubName string MsgChannelSubName string
SliceIndex int SliceIndex int
// segcore
ChunkSize int64
Log log.Config Log log.Config
} }
...@@ -111,6 +114,8 @@ func (p *ParamTable) Init() { ...@@ -111,6 +114,8 @@ func (p *ParamTable) Init() {
p.initStatsPublishInterval() p.initStatsPublishInterval()
p.initStatsChannelName() p.initStatsChannelName()
p.initSegcoreChunkSize()
p.initLogCfg() p.initLogCfg()
}) })
} }
...@@ -254,6 +259,10 @@ func (p *ParamTable) initStatsChannelName() { ...@@ -254,6 +259,10 @@ func (p *ParamTable) initStatsChannelName() {
p.StatsChannelName = channels p.StatsChannelName = channels
} }
func (p *ParamTable) initSegcoreChunkSize() {
p.ChunkSize = p.ParseInt64("queryNode.segcore.chunkSize")
}
func (p *ParamTable) initLogCfg() { func (p *ParamTable) initLogCfg() {
p.Log = log.Config{} p.Log = log.Config{}
format, err := p.Load("log.format") format, err := p.Load("log.format")
......
...@@ -29,7 +29,6 @@ import ( ...@@ -29,7 +29,6 @@ import (
"errors" "errors"
"strconv" "strconv"
"sync/atomic" "sync/atomic"
"unsafe"
"go.uber.org/zap" "go.uber.org/zap"
...@@ -99,6 +98,14 @@ func (node *QueryNode) Register() error { ...@@ -99,6 +98,14 @@ func (node *QueryNode) Register() error {
return nil return nil
} }
func (node *QueryNode) InitSegcore() {
C.SegcoreInit()
// override segcore chunk size
cChunkSize := C.int64_t(Params.ChunkSize)
C.SegcoreSetChunkSize(cChunkSize)
}
func (node *QueryNode) Init() error { func (node *QueryNode) Init() error {
//ctx := context.Background() //ctx := context.Background()
connectEtcdFn := func() error { connectEtcdFn := func() error {
...@@ -124,9 +131,7 @@ func (node *QueryNode) Init() error { ...@@ -124,9 +131,7 @@ func (node *QueryNode) Init() error {
node.etcdKV) node.etcdKV)
node.streaming = newStreaming(node.queryNodeLoopCtx, node.msFactory, node.etcdKV) node.streaming = newStreaming(node.queryNodeLoopCtx, node.msFactory, node.etcdKV)
cConfigDir := C.CString(Params.BaseTable.GetConfigDir()) node.InitSegcore()
C.SegcoreInit(cConfigDir)
C.free(unsafe.Pointer(cConfigDir))
if node.rootCoord == nil { if node.rootCoord == nil {
log.Error("null root coordinator detected") log.Error("null root coordinator detected")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册