From 82eb69fbedefb9eb16a39a93a6ac0009a3fb1c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=9B=9B=E4=BF=8A?= <49774184+shengjun1985@users.noreply.github.com> Date: Sat, 4 Jan 2020 15:52:48 +0800 Subject: [PATCH] remove redundant checks (#860) (#907) * delete redundant check (#860) * add changelog Co-authored-by: Jin Hai --- CHANGELOG.md | 1 + core/src/cache/CpuCacheMgr.cpp | 19 ++++--------------- core/src/cache/GpuCacheMgr.cpp | 19 ++++--------------- 3 files changed, 9 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bd943820b..10c6a8f166 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Please mark all change in change log and use the issue from GitHub - \#791 - Remove Arrow - \#834 - add cpu mode for built-in Faiss - \#848 - Add ready-to-use config files to the Milvus repo for enhanced user experince +- \#860 - Remove redundant checks in CacheMgr's constructor - \#908 - Move "primary_path" and "secondary_path" to storage config ## Task diff --git a/core/src/cache/CpuCacheMgr.cpp b/core/src/cache/CpuCacheMgr.cpp index 1f560cbf8d..0a685c6c1e 100644 --- a/core/src/cache/CpuCacheMgr.cpp +++ b/core/src/cache/CpuCacheMgr.cpp @@ -29,28 +29,17 @@ constexpr int64_t unit = 1024 * 1024 * 1024; } CpuCacheMgr::CpuCacheMgr() { + // All config values have been checked in Config::ValidateConfig() server::Config& config = server::Config::GetInstance(); - Status s; int64_t cpu_cache_cap; - s = config.GetCacheConfigCpuCacheCapacity(cpu_cache_cap); - if (!s.ok()) { - SERVER_LOG_ERROR << s.message(); - } + config.GetCacheConfigCpuCacheCapacity(cpu_cache_cap); int64_t cap = cpu_cache_cap * unit; cache_ = std::make_shared>(cap, 1UL << 32); float cpu_cache_threshold; - s = config.GetCacheConfigCpuCacheThreshold(cpu_cache_threshold); - if (!s.ok()) { - SERVER_LOG_ERROR << s.message(); - } - if (cpu_cache_threshold > 0.0 && cpu_cache_threshold <= 1.0) { - cache_->set_freemem_percent(cpu_cache_threshold); - } else { - SERVER_LOG_ERROR << "Invalid cpu_cache_threshold: " << cpu_cache_threshold << ", by default set to " - << cache_->freemem_percent(); - } + config.GetCacheConfigCpuCacheThreshold(cpu_cache_threshold); + cache_->set_freemem_percent(cpu_cache_threshold); } CpuCacheMgr* diff --git a/core/src/cache/GpuCacheMgr.cpp b/core/src/cache/GpuCacheMgr.cpp index 1802fb3935..8437304fc6 100644 --- a/core/src/cache/GpuCacheMgr.cpp +++ b/core/src/cache/GpuCacheMgr.cpp @@ -34,28 +34,17 @@ constexpr int64_t G_BYTE = 1024 * 1024 * 1024; } GpuCacheMgr::GpuCacheMgr() { + // All config values have been checked in Config::ValidateConfig() server::Config& config = server::Config::GetInstance(); - Status s; int64_t gpu_cache_cap; - s = config.GetGpuResourceConfigCacheCapacity(gpu_cache_cap); - if (!s.ok()) { - SERVER_LOG_ERROR << s.message(); - } + config.GetGpuResourceConfigCacheCapacity(gpu_cache_cap); int64_t cap = gpu_cache_cap * G_BYTE; cache_ = std::make_shared>(cap, 1UL << 32); float gpu_mem_threshold; - s = config.GetGpuResourceConfigCacheThreshold(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 { - SERVER_LOG_ERROR << "Invalid gpu_mem_threshold: " << gpu_mem_threshold << ", by default set to " - << cache_->freemem_percent(); - } + config.GetGpuResourceConfigCacheThreshold(gpu_mem_threshold); + cache_->set_freemem_percent(gpu_mem_threshold); } GpuCacheMgr*