Commit 3135201d authored by 蔡宇东's avatar 蔡宇东
Browse files

MS-574 let all config APIs return Status


Former-commit-id: 8289e85dd7fe5c8c884652bb8b1ff5f39d3eefbc
parent 5af187bc
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -30,10 +30,21 @@ namespace {

CpuCacheMgr::CpuCacheMgr() {
    server::Config& config = server::Config::GetInstance();
    int64_t cap = config.GetCacheConfigCpuMemCapacity() * unit;
    Status s;

    int32_t cpu_mem_cap;
    s = config.GetCacheConfigCpuMemCapacity(cpu_mem_cap);
    if (!s.ok()) {
        SERVER_LOG_ERROR << s.message();
    }
    int64_t cap = cpu_mem_cap * unit;
    cache_ = std::make_shared<Cache<DataObjPtr>>(cap, 1UL<<32);

    float cpu_mem_threshold = config.GetCacheConfigCpuMemThreshold();
    float cpu_mem_threshold;
    s = config.GetCacheConfigCpuMemThreshold(cpu_mem_threshold);
    if (!s.ok()) {
        SERVER_LOG_ERROR << s.message();
    }
    if (cpu_mem_threshold > 0.0 && cpu_mem_threshold <= 1.0) {
        cache_->set_freemem_percent(cpu_mem_threshold);
    } else {
+12 −2
Original line number Diff line number Diff line
@@ -34,11 +34,21 @@ namespace {

GpuCacheMgr::GpuCacheMgr() {
    server::Config& config = server::Config::GetInstance();
    Status s;

    int32_t cap = config.GetCacheConfigGpuMemCapacity() * G_BYTE;
    int32_t gpu_mem_cap;
    s = config.GetCacheConfigGpuMemCapacity(gpu_mem_cap);
    if (!s.ok()) {
        SERVER_LOG_ERROR << s.message();
    }
    int32_t cap = gpu_mem_cap * G_BYTE;
    cache_ = std::make_shared<Cache<DataObjPtr>>(cap, 1UL<<32);

    float gpu_mem_threshold = config.GetCacheConfigGpuMemThreshold();
    float gpu_mem_threshold;
    s = config.GetCacheConfigGpuMemThreshold(gpu_mem_threshold);
    if (!s.ok()) {
        SERVER_LOG_ERROR << s.message();
    }
    if (gpu_mem_threshold > 0.0 && gpu_mem_threshold <= 1.0) {
        cache_->set_freemem_percent(gpu_mem_threshold);
    } else {
+2 −1
Original line number Diff line number Diff line
@@ -336,7 +336,8 @@ Status ExecutionEngineImpl::GpuCache(uint64_t gpu_id) {
Status ExecutionEngineImpl::Init() {
    using namespace zilliz::milvus::server;
    server::Config &config = server::Config::GetInstance();
    gpu_num_ = config.GetDBConfigBuildIndexGPU();
    Status s = config.GetDBConfigBuildIndexGPU(gpu_num_);
    if (!s.ok()) return s;

    return Status::OK();
}
+1 −1
Original line number Diff line number Diff line
@@ -101,7 +101,7 @@ protected:
    std::string location_;

    int32_t nlist_ = 0;
    int64_t gpu_num_ = 0;
    int32_t gpu_num_ = 0;
};


+3 −1
Original line number Diff line number Diff line
@@ -33,7 +33,9 @@ Metrics::GetInstance() {
MetricsBase &
Metrics::CreateMetricsCollector() {
    Config &config = Config::GetInstance();
    std::string collector_type_str = config.GetMetricConfigCollector();
    std::string collector_type_str;

    config.GetMetricConfigCollector(collector_type_str);

    if (collector_type_str == "prometheus") {
        return PrometheusMetrics::GetInstance();
Loading