mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-07 01:28:27 +08:00
Support easylogging config for segcore and knowhere (#16751)
Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
parent
d5db4ae463
commit
6a62ff18bf
25
configs/easylogging.yaml
Normal file
25
configs/easylogging.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
* GLOBAL:
|
||||||
|
FORMAT = "%datetime | %level | %logger | %msg"
|
||||||
|
FILENAME = "/var/lib/milvus/logs/milvus-%datetime{%y-%M-%d-%H:%m}-easylog.log"
|
||||||
|
ENABLED = false
|
||||||
|
TO_FILE = false
|
||||||
|
TO_STANDARD_OUTPUT = false
|
||||||
|
SUBSECOND_PRECISION = 3
|
||||||
|
PERFORMANCE_TRACKING = false
|
||||||
|
MAX_LOG_FILE_SIZE = 209715200 ## Throw log files away after 200MB
|
||||||
|
* INFO:
|
||||||
|
ENABLED = false
|
||||||
|
* TRACE:
|
||||||
|
ENABLED = false
|
||||||
|
* DEBUG:
|
||||||
|
ENABLED = false
|
||||||
|
* WARNING:
|
||||||
|
ENABLED = false
|
||||||
|
* ERROR:
|
||||||
|
ENABLED = true
|
||||||
|
* FATAL:
|
||||||
|
ENABLED = true
|
||||||
|
* VERBOSE:
|
||||||
|
FORMAT = "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
|
||||||
|
TO_FILE = false
|
||||||
|
TO_STANDARD_OUTPUT = false
|
||||||
@ -27,23 +27,24 @@ namespace milvus::config {
|
|||||||
std::once_flag init_knowhere_once_;
|
std::once_flag init_knowhere_once_;
|
||||||
|
|
||||||
void
|
void
|
||||||
KnowhereInitImpl() {
|
KnowhereInitImpl(const char* conf_file) {
|
||||||
auto init = []() {
|
auto init = [&]() {
|
||||||
knowhere::KnowhereConfig::SetBlasThreshold(16384);
|
knowhere::KnowhereConfig::SetBlasThreshold(16384);
|
||||||
knowhere::KnowhereConfig::SetEarlyStopThreshold(0);
|
knowhere::KnowhereConfig::SetEarlyStopThreshold(0);
|
||||||
knowhere::KnowhereConfig::SetLogHandler();
|
knowhere::KnowhereConfig::SetLogHandler();
|
||||||
knowhere::KnowhereConfig::SetStatisticsLevel(0);
|
knowhere::KnowhereConfig::SetStatisticsLevel(0);
|
||||||
|
|
||||||
|
#ifdef EMBEDDED_MILVUS
|
||||||
|
// always disable all logs for embedded milvus.
|
||||||
el::Configurations el_conf;
|
el::Configurations el_conf;
|
||||||
el_conf.setGlobally(el::ConfigurationType::Enabled, std::to_string(false));
|
el_conf.setGlobally(el::ConfigurationType::Enabled, "false");
|
||||||
#if defined(EMBEDDED_MILVUS)
|
el::Loggers::reconfigureAllLoggers(el_conf);
|
||||||
// Disable all logs for embedded milvus.
|
#else
|
||||||
el_conf.set(el::Level::Trace, el::ConfigurationType::Enabled, "false");
|
if (conf_file != nullptr) {
|
||||||
el_conf.set(el::Level::Debug, el::ConfigurationType::Enabled, "false");
|
el::Configurations el_conf(conf_file);
|
||||||
el_conf.set(el::Level::Info, el::ConfigurationType::Enabled, "false");
|
el::Loggers::reconfigureAllLoggers(el_conf);
|
||||||
el_conf.set(el::Level::Warning, el::ConfigurationType::Enabled, "false");
|
LOG_SERVER_DEBUG_ << "Config easylogging with yaml file: " << conf_file;
|
||||||
el_conf.set(el::Level::Error, el::ConfigurationType::Enabled, "false");
|
}
|
||||||
el_conf.set(el::Level::Fatal, el::ConfigurationType::Enabled, "false");
|
|
||||||
el::Loggers::reconfigureLogger("default", el_conf);
|
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
namespace milvus::config {
|
namespace milvus::config {
|
||||||
|
|
||||||
void
|
void
|
||||||
KnowhereInitImpl();
|
KnowhereInitImpl(const char*);
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
KnowhereSetSimdType(const char*);
|
KnowhereSetSimdType(const char*);
|
||||||
|
|||||||
@ -14,8 +14,8 @@
|
|||||||
#include "indexbuilder/init_c.h"
|
#include "indexbuilder/init_c.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
IndexBuilderInit() {
|
IndexBuilderInit(const char* conf_file) {
|
||||||
milvus::config::KnowhereInitImpl();
|
milvus::config::KnowhereInitImpl(conf_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// return value must be freed by the caller
|
// return value must be freed by the caller
|
||||||
|
|||||||
@ -16,7 +16,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
IndexBuilderInit();
|
IndexBuilderInit(const char*);
|
||||||
|
|
||||||
// return value must be freed by the caller
|
// return value must be freed by the caller
|
||||||
char*
|
char*
|
||||||
|
|||||||
@ -16,20 +16,8 @@
|
|||||||
|
|
||||||
namespace milvus::segcore {
|
namespace milvus::segcore {
|
||||||
extern "C" void
|
extern "C" void
|
||||||
SegcoreInit() {
|
SegcoreInit(const char* conf_file) {
|
||||||
milvus::config::KnowhereInitImpl();
|
milvus::config::KnowhereInitImpl(conf_file);
|
||||||
#if defined(EMBEDDED_MILVUS)
|
|
||||||
el::Configurations defaultConf;
|
|
||||||
defaultConf.setToDefault();
|
|
||||||
// Disable all logs for embedded milvus.
|
|
||||||
defaultConf.set(el::Level::Trace, el::ConfigurationType::Enabled, "false");
|
|
||||||
defaultConf.set(el::Level::Debug, el::ConfigurationType::Enabled, "false");
|
|
||||||
defaultConf.set(el::Level::Info, el::ConfigurationType::Enabled, "false");
|
|
||||||
defaultConf.set(el::Level::Warning, el::ConfigurationType::Enabled, "false");
|
|
||||||
defaultConf.set(el::Level::Error, el::ConfigurationType::Enabled, "false");
|
|
||||||
defaultConf.set(el::Level::Fatal, el::ConfigurationType::Enabled, "false");
|
|
||||||
el::Loggers::reconfigureLogger("default", defaultConf);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void
|
extern "C" void
|
||||||
|
|||||||
@ -16,7 +16,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
SegcoreInit();
|
SegcoreInit(const char*);
|
||||||
|
|
||||||
void
|
void
|
||||||
SegcoreSetChunkRows(const int64_t);
|
SegcoreSetChunkRows(const int64_t);
|
||||||
|
|||||||
@ -17,7 +17,7 @@
|
|||||||
TEST(Init, Naive) {
|
TEST(Init, Naive) {
|
||||||
using namespace milvus;
|
using namespace milvus;
|
||||||
using namespace milvus::segcore;
|
using namespace milvus::segcore;
|
||||||
SegcoreInit();
|
SegcoreInit(nullptr);
|
||||||
SegcoreSetChunkRows(32768);
|
SegcoreSetChunkRows(32768);
|
||||||
SegcoreSetSimdType("auto");
|
SegcoreSetSimdType("auto");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
@ -146,7 +147,9 @@ func (i *IndexNode) Register() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (i *IndexNode) initKnowhere() {
|
func (i *IndexNode) initKnowhere() {
|
||||||
C.IndexBuilderInit()
|
cEasyloggingYaml := C.CString(path.Join(Params.BaseTable.GetConfigDir(), paramtable.DefaultEasyloggingYaml))
|
||||||
|
C.IndexBuilderInit(cEasyloggingYaml)
|
||||||
|
C.free(unsafe.Pointer(cEasyloggingYaml))
|
||||||
|
|
||||||
// override index builder SIMD type
|
// override index builder SIMD type
|
||||||
cSimdType := C.CString(Params.CommonCfg.SimdType)
|
cSimdType := C.CString(Params.CommonCfg.SimdType)
|
||||||
|
|||||||
@ -36,6 +36,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
@ -176,7 +177,9 @@ func (node *QueryNode) Register() error {
|
|||||||
|
|
||||||
// InitSegcore set init params of segCore, such as chunckRows, SIMD type...
|
// InitSegcore set init params of segCore, such as chunckRows, SIMD type...
|
||||||
func (node *QueryNode) InitSegcore() {
|
func (node *QueryNode) InitSegcore() {
|
||||||
C.SegcoreInit()
|
cEasyloggingYaml := C.CString(path.Join(Params.BaseTable.GetConfigDir(), paramtable.DefaultEasyloggingYaml))
|
||||||
|
C.SegcoreInit(cEasyloggingYaml)
|
||||||
|
C.free(unsafe.Pointer(cEasyloggingYaml))
|
||||||
|
|
||||||
// override segcore chunk size
|
// override segcore chunk size
|
||||||
cChunkRows := C.int64_t(Params.QueryNodeCfg.ChunkRows)
|
cChunkRows := C.int64_t(Params.QueryNodeCfg.ChunkRows)
|
||||||
|
|||||||
@ -35,6 +35,8 @@ import (
|
|||||||
type UniqueID = typeutil.UniqueID
|
type UniqueID = typeutil.UniqueID
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
DefaultMilvusYaml = "milvus.yaml"
|
||||||
|
DefaultEasyloggingYaml = "easylogging.yaml"
|
||||||
DefaultMinioHost = "localhost"
|
DefaultMinioHost = "localhost"
|
||||||
DefaultMinioPort = "9000"
|
DefaultMinioPort = "9000"
|
||||||
DefaultMinioAccessKey = "minioadmin"
|
DefaultMinioAccessKey = "minioadmin"
|
||||||
@ -49,7 +51,7 @@ const (
|
|||||||
DefaultEnvPrefix = "milvus"
|
DefaultEnvPrefix = "milvus"
|
||||||
)
|
)
|
||||||
|
|
||||||
var DefaultYaml = "milvus.yaml"
|
var defaultYaml = DefaultMilvusYaml
|
||||||
|
|
||||||
// Base abstracts BaseTable
|
// Base abstracts BaseTable
|
||||||
// TODO: it's never used, consider to substitute BaseTable or to remove it
|
// TODO: it's never used, consider to substitute BaseTable or to remove it
|
||||||
@ -79,7 +81,7 @@ type BaseTable struct {
|
|||||||
// GlobalInitWithYaml should be called only in standalone and embedded Milvus.
|
// GlobalInitWithYaml should be called only in standalone and embedded Milvus.
|
||||||
func (gp *BaseTable) GlobalInitWithYaml(yaml string) {
|
func (gp *BaseTable) GlobalInitWithYaml(yaml string) {
|
||||||
gp.once.Do(func() {
|
gp.once.Do(func() {
|
||||||
DefaultYaml = yaml
|
defaultYaml = yaml
|
||||||
gp.Init()
|
gp.Init()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -88,7 +90,7 @@ func (gp *BaseTable) GlobalInitWithYaml(yaml string) {
|
|||||||
func (gp *BaseTable) Init() {
|
func (gp *BaseTable) Init() {
|
||||||
gp.params = memkv.NewMemoryKV()
|
gp.params = memkv.NewMemoryKV()
|
||||||
gp.configDir = gp.initConfPath()
|
gp.configDir = gp.initConfPath()
|
||||||
gp.loadFromYaml(DefaultYaml)
|
gp.loadFromYaml(defaultYaml)
|
||||||
gp.tryLoadFromEnv()
|
gp.tryLoadFromEnv()
|
||||||
gp.InitLogCfg()
|
gp.InitLogCfg()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,6 @@ import (
|
|||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
const defaultYaml = "milvus.yaml"
|
|
||||||
|
|
||||||
var baseParams = BaseTable{}
|
var baseParams = BaseTable{}
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user