diff --git a/CHANGELOG.md b/CHANGELOG.md index d875f5b1af..9d8d1ea304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Please mark all change in change log and use the issue from GitHub - \#2363 Update branch version to 0.9.1 ## Improvement +- \#2370 Clean compile warning ## Task diff --git a/core/src/cache/Cache.inl b/core/src/cache/Cache.inl index 561cdb3a42..c371efe515 100644 --- a/core/src/cache/Cache.inl +++ b/core/src/cache/Cache.inl @@ -16,9 +16,9 @@ constexpr double DEFAULT_THRESHOLD_PERCENT = 0.7; template Cache::Cache(int64_t capacity, int64_t cache_max_count, const std::string& header) - : usage_(0), + : header_(header), + usage_(0), capacity_(capacity), - header_(header), freemem_percent_(DEFAULT_THRESHOLD_PERCENT), lru_(cache_max_count) { } diff --git a/core/src/db/DBImpl.cpp b/core/src/db/DBImpl.cpp index 03276c2c80..f8a5a5bfa5 100644 --- a/core/src/db/DBImpl.cpp +++ b/core/src/db/DBImpl.cpp @@ -1977,7 +1977,7 @@ DBImpl::MergeHybridFiles(const std::string& collection_id, meta::FilesHolder& fi auto file_schema = file; file_schema.file_type_ = meta::SegmentSchema::TO_DELETE; updated.push_back(file_schema); - auto size = segment_writer_ptr->Size(); + int64_t size = segment_writer_ptr->Size(); if (size >= file_schema.index_file_size_) { break; } @@ -2558,6 +2558,9 @@ DBImpl::ExecWalRecord(const wal::MXLogRecord& record) { } break; } + + default: + break; } return status; diff --git a/core/src/db/IDGenerator.cpp b/core/src/db/IDGenerator.cpp index cbc38f31f0..46f751ce40 100644 --- a/core/src/db/IDGenerator.cpp +++ b/core/src/db/IDGenerator.cpp @@ -47,7 +47,7 @@ SimpleIDGenerator::NextIDNumbers(size_t n, IDNumbers& ids) { auto micros = std::chrono::duration_cast(now.time_since_epoch()).count(); micros *= MAX_IDS_PER_MICRO; - for (int pos = 0; pos < n; ++pos) { + for (size_t pos = 0; pos < n; ++pos) { ids.push_back(micros + pos); } return Status::OK(); @@ -114,7 +114,7 @@ SafeIDGenerator::NextIDNumbers(size_t n, IDNumbers& ids) { int64_t ID_high_part = time_stamp_ms_ * MAX_IDS_PER_MICRO; - for (int pos = 0; pos < n; ++pos) { + for (size_t pos = 0; pos < n; ++pos) { ids.push_back(ID_high_part + pos); } diff --git a/core/src/db/Options.cpp b/core/src/db/Options.cpp index e2dbfdfcf0..9e82772fad 100644 --- a/core/src/db/Options.cpp +++ b/core/src/db/Options.cpp @@ -22,6 +22,10 @@ namespace milvus { namespace engine { +const char* ARCHIVE_CONF_DISK = "disk"; +const char* ARCHIVE_CONF_DAYS = "days"; +const char* DEFAULT_PARTITON_TAG = "_default"; + ArchiveConf::ArchiveConf(const std::string& type, const std::string& criterias) { ParseType(type); ParseCritirias(criterias); diff --git a/core/src/db/Options.h b/core/src/db/Options.h index b446d049ec..c2fc7de597 100644 --- a/core/src/db/Options.h +++ b/core/src/db/Options.h @@ -23,8 +23,9 @@ namespace engine { class Env; -static const char* ARCHIVE_CONF_DISK = "disk"; -static const char* ARCHIVE_CONF_DAYS = "days"; +extern const char* ARCHIVE_CONF_DISK; +extern const char* ARCHIVE_CONF_DAYS; +extern const char* DEFAULT_PARTITON_TAG; struct ArchiveConf { using CriteriaT = std::map; diff --git a/core/src/db/Types.h b/core/src/db/Types.h index 6e212f6bb5..0f25dff82c 100644 --- a/core/src/db/Types.h +++ b/core/src/db/Types.h @@ -59,7 +59,5 @@ struct Entity { using File2ErrArray = std::map>; using Table2FileErr = std::map; -static const char* DEFAULT_PARTITON_TAG = "_default"; - } // namespace engine } // namespace milvus diff --git a/core/src/db/Utils.cpp b/core/src/db/Utils.cpp index f7327f4096..5769f2b510 100644 --- a/core/src/db/Utils.cpp +++ b/core/src/db/Utils.cpp @@ -249,8 +249,6 @@ GetDate(const std::time_t& t, int day_delta) { ++day_delta; } while (day_delta < 0); mktime(<m); - } else { - ltm.tm_mday; } return ltm.tm_year * 10000 + ltm.tm_mon * 100 + ltm.tm_mday; } diff --git a/core/src/db/engine/ExecutionEngineImpl.cpp b/core/src/db/engine/ExecutionEngineImpl.cpp index ffe144dabb..6220710d14 100644 --- a/core/src/db/engine/ExecutionEngineImpl.cpp +++ b/core/src/db/engine/ExecutionEngineImpl.cpp @@ -804,7 +804,7 @@ ExecutionEngineImpl::ExecBinaryQuery(milvus::query::GeneralQueryPtr general_quer } if (general_query->leaf == nullptr) { - Status status; + Status status = Status::OK(); if (general_query->bin->left_query != nullptr) { status = ExecBinaryQuery(general_query->bin->left_query, bitset, attr_type, nq, topk, distances, labels); } @@ -986,6 +986,8 @@ ExecutionEngineImpl::ExecBinaryQuery(milvus::query::GeneralQueryPtr general_quer } break; } + default: + break; } return Status::OK(); } @@ -1049,6 +1051,8 @@ ExecutionEngineImpl::ExecBinaryQuery(milvus::query::GeneralQueryPtr general_quer ProcessRangeQuery(data, value, com_expr[j].compare_operator, bitset); break; } + default: + break; } } return Status::OK(); @@ -1075,6 +1079,7 @@ ExecutionEngineImpl::ExecBinaryQuery(milvus::query::GeneralQueryPtr general_quer distances.data(), labels.data()); } } + return Status::OK(); } Status diff --git a/core/src/db/engine/ExecutionEngineImpl.h b/core/src/db/engine/ExecutionEngineImpl.h index 3add035ad3..218f72bc7e 100644 --- a/core/src/db/engine/ExecutionEngineImpl.h +++ b/core/src/db/engine/ExecutionEngineImpl.h @@ -121,6 +121,8 @@ class ExecutionEngineImpl : public ExecutionEngine { protected: knowhere::VecIndexPtr index_ = nullptr; + std::string location_; + int64_t dim_; EngineType index_type_; MetricType metric_type_; @@ -130,9 +132,6 @@ class ExecutionEngineImpl : public ExecutionEngine { query::BinaryQueryPtr binary_query_; int64_t vector_count_; - int64_t dim_; - std::string location_; - milvus::json index_params_; int64_t gpu_num_ = 0; }; diff --git a/core/src/db/insert/MemTable.cpp b/core/src/db/insert/MemTable.cpp index fea0b6fcda..db71f02c71 100644 --- a/core/src/db/insert/MemTable.cpp +++ b/core/src/db/insert/MemTable.cpp @@ -339,7 +339,7 @@ MemTable::ApplyDeletes() { rec.RecordSection("Find uids and set deleted docs and bloom filter"); - for (auto i = 0; i < indexes.size(); ++i) { + for (size_t i = 0; i < indexes.size(); ++i) { indexes[i]->SetBlacklist(blacklists[i]); } diff --git a/core/src/db/insert/MemTableFile.cpp b/core/src/db/insert/MemTableFile.cpp index b48a1b77c0..208f354da5 100644 --- a/core/src/db/insert/MemTableFile.cpp +++ b/core/src/db/insert/MemTableFile.cpp @@ -182,7 +182,7 @@ MemTableFile::IsFull() { Status MemTableFile::Serialize(uint64_t wal_lsn) { - size_t size = GetCurrentMem(); + int64_t size = GetCurrentMem(); server::CollectSerializeMetrics metrics(size); auto status = segment_writer_ptr_->Serialize(); diff --git a/core/src/db/merge/MergeLayeredStrategy.cpp b/core/src/db/merge/MergeLayeredStrategy.cpp index 58dbc3ee5d..f5ab9a9ffa 100644 --- a/core/src/db/merge/MergeLayeredStrategy.cpp +++ b/core/src/db/merge/MergeLayeredStrategy.cpp @@ -39,7 +39,7 @@ MergeLayeredStrategy::RegroupFiles(meta::FilesHolder& files_holder, MergeFilesGr // iterater from end, because typically the files_holder get files in order from largest to smallest for (meta::SegmentsSchema::reverse_iterator iter = files.rbegin(); iter != files.rend(); ++iter) { meta::SegmentSchema& file = *iter; - if (file.index_file_size_ > 0 && file.file_size_ > file.index_file_size_) { + if (file.index_file_size_ > 0 && file.file_size_ > (size_t)(file.index_file_size_)) { // release file that no need to merge files_holder.UnmarkFile(file); continue; @@ -77,7 +77,7 @@ MergeLayeredStrategy::RegroupFiles(meta::FilesHolder& files_holder, MergeFilesGr // layer only has one file, if the file is too old, force merge it, else no need to merge it if (pair.second.size() == 1) { - if (now - pair.second[0].created_on_ > FORCE_MERGE_THREASHOLD * meta::US_PS) { + if (now - pair.second[0].created_on_ > (int64_t)(FORCE_MERGE_THREASHOLD * meta::US_PS)) { force_merge_file.push_back(pair.second[0]); pair.second.clear(); } diff --git a/core/src/db/meta/Meta.cpp b/core/src/db/meta/Meta.cpp new file mode 100644 index 0000000000..252e4fa4e1 --- /dev/null +++ b/core/src/db/meta/Meta.cpp @@ -0,0 +1,27 @@ +// 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. + +#include "db/meta/Meta.h" + +namespace milvus { +namespace engine { +namespace meta { + +const char* META_ENVIRONMENT = "Environment"; +const char* META_TABLES = "Tables"; +const char* META_TABLEFILES = "TableFiles"; +const char* META_COLLECTIONS = "Collections"; +const char* META_FIELDS = "Fields"; +const char* META_COLLECTIONFILES = "CollectionFiles"; + +} // namespace meta +} // namespace engine +} // namespace milvus diff --git a/core/src/db/meta/Meta.h b/core/src/db/meta/Meta.h index 17aa780fb7..abb26b2db1 100644 --- a/core/src/db/meta/Meta.h +++ b/core/src/db/meta/Meta.h @@ -26,12 +26,12 @@ namespace milvus { namespace engine { namespace meta { -static const char* META_ENVIRONMENT = "Environment"; -static const char* META_TABLES = "Tables"; -static const char* META_TABLEFILES = "TableFiles"; -static const char* META_COLLECTIONS = "Collections"; -static const char* META_FIELDS = "Fields"; -static const char* META_COLLECTIONFILES = "CollectionFiles"; +extern const char* META_ENVIRONMENT; +extern const char* META_TABLES; +extern const char* META_TABLEFILES; +extern const char* META_COLLECTIONS; +extern const char* META_FIELDS; +extern const char* META_COLLECTIONFILES; class FilesHolder; diff --git a/core/src/db/meta/MetaConsts.h b/core/src/db/meta/MetaConsts.h index f41c5b6675..4ae31ca52d 100644 --- a/core/src/db/meta/MetaConsts.h +++ b/core/src/db/meta/MetaConsts.h @@ -31,7 +31,7 @@ const size_t WEEK = 7 * DAY; // 1. The performance of brute-search for small raw files could be better than small index file. // 2. And small raw files can be merged to larger files, thus reduce fragmented files count. // We decide the value based on a testing for small size raw/index files. -const size_t BUILD_INDEX_THRESHOLD = 5000; +const size_t BUILD_INDEX_THRESHOLD = 4096; } // namespace meta } // namespace engine diff --git a/core/src/db/wal/WalMetaHandler.cpp b/core/src/db/wal/WalMetaHandler.cpp index 2d6812cd81..d6a3483c77 100644 --- a/core/src/db/wal/WalMetaHandler.cpp +++ b/core/src/db/wal/WalMetaHandler.cpp @@ -17,6 +17,8 @@ namespace milvus { namespace engine { namespace wal { +const char* WAL_META_FILE_NAME = "mxlog.meta"; + MXLogMetaHandler::MXLogMetaHandler(const std::string& internal_meta_file_path) { std::string file_full_path = internal_meta_file_path + WAL_META_FILE_NAME; diff --git a/core/src/db/wal/WalMetaHandler.h b/core/src/db/wal/WalMetaHandler.h index 4452d7246c..a43d6cd4c5 100644 --- a/core/src/db/wal/WalMetaHandler.h +++ b/core/src/db/wal/WalMetaHandler.h @@ -25,7 +25,7 @@ namespace milvus { namespace engine { namespace wal { -static const char* WAL_META_FILE_NAME = "mxlog.meta"; +extern const char* WAL_META_FILE_NAME; class MXLogMetaHandler { public: diff --git a/core/src/index/knowhere/knowhere/index/vector_index/ConfAdapter.cpp b/core/src/index/knowhere/knowhere/index/vector_index/ConfAdapter.cpp index 3d438d5021..3a1ec6cf70 100644 --- a/core/src/index/knowhere/knowhere/index/vector_index/ConfAdapter.cpp +++ b/core/src/index/knowhere/knowhere/index/vector_index/ConfAdapter.cpp @@ -40,11 +40,6 @@ namespace knowhere { return false; \ } -// #define checkfloat(key, min, max) \ -// if (!oricfg.contains(key) || !oricfg[key].is_number_float() || oricfg[key] >= max || oricfg[key] <= min) { \ -// return false; \ -// } - #define CheckIntByValues(key, container) \ if (!oricfg.contains(key) || !oricfg[key].is_number_integer()) { \ return false; \ diff --git a/core/src/index/thirdparty/hnswlib/hnswalg.h b/core/src/index/thirdparty/hnswlib/hnswalg.h index 244fea6cc1..8c54c8c39f 100644 --- a/core/src/index/thirdparty/hnswlib/hnswalg.h +++ b/core/src/index/thirdparty/hnswlib/hnswalg.h @@ -618,8 +618,6 @@ class HierarchicalNSW : public AlgorithmInterface { } void loadIndex(milvus::knowhere::MemoryIOReader& input, size_t max_elements_i = 0) { - auto totoal_filesize = input.total; - // linxj: init with metrictype size_t dim = 100; readBinaryPOD(input, metric_type_); diff --git a/core/src/metrics/SystemInfo.cpp b/core/src/metrics/SystemInfo.cpp index c789edb797..ced48b31c7 100644 --- a/core/src/metrics/SystemInfo.cpp +++ b/core/src/metrics/SystemInfo.cpp @@ -85,7 +85,7 @@ SystemInfo::Init() { // initialize network traffic information try { - std::pair in_and_out_octets = Octets(); + std::pair in_and_out_octets = Octets(); in_octets_ = in_and_out_octets.first; out_octets_ = in_and_out_octets.second; net_time_ = std::chrono::system_clock::now(); @@ -95,7 +95,7 @@ SystemInfo::Init() { } } -uint64_t +int64_t SystemInfo::ParseLine(char* line) { // This assumes that a digit will be found and the line ends in " Kb". int i = strlen(line); @@ -105,29 +105,29 @@ SystemInfo::ParseLine(char* line) { } line[i - 3] = '\0'; i = atoi(p); - return static_cast(i); + return i; } -uint64_t +int64_t SystemInfo::GetPhysicalMemory() { struct sysinfo memInfo; sysinfo(&memInfo); - uint64_t totalPhysMem = memInfo.totalram; + int64_t totalPhysMem = memInfo.totalram; // Multiply in next statement to avoid int overflow on right hand side... totalPhysMem *= memInfo.mem_unit; return totalPhysMem; } -uint64_t +int64_t SystemInfo::GetProcessUsedMemory() { try { // Note: this value is in KB! FILE* file = fopen("/proc/self/status", "r"); - uint64_t result = 0; - constexpr uint64_t KB_SIZE = 1024; + int64_t result = 0; + constexpr int64_t KB = 1024; if (file) { - constexpr uint64_t line_length = 128; + constexpr int64_t line_length = 128; char line[line_length]; while (fgets(line, line_length, file) != nullptr) { @@ -142,7 +142,7 @@ SystemInfo::GetProcessUsedMemory() { } // return value in Byte - return (result * KB_SIZE); + return (result * KB); } catch (std::exception& ex) { std::string msg = "Failed to read /proc/self/status, reason: " + std::string(ex.what()); LOG_SERVER_ERROR_ << msg; @@ -163,11 +163,11 @@ SystemInfo::MemoryPercent() { std::vector SystemInfo::CPUCorePercent() { - std::vector prev_work_time_array; - std::vector prev_total_time_array = getTotalCpuTime(prev_work_time_array); + std::vector prev_work_time_array; + std::vector prev_total_time_array = getTotalCpuTime(prev_work_time_array); usleep(100000); - std::vector cur_work_time_array; - std::vector cur_total_time_array = getTotalCpuTime(cur_work_time_array); + std::vector cur_work_time_array; + std::vector cur_total_time_array = getTotalCpuTime(cur_work_time_array); std::vector cpu_core_percent; for (int i = 0; i < cur_total_time_array.size(); i++) { @@ -178,9 +178,9 @@ SystemInfo::CPUCorePercent() { return cpu_core_percent; } -std::vector -SystemInfo::getTotalCpuTime(std::vector& work_time_array) { - std::vector total_time_array; +std::vector +SystemInfo::getTotalCpuTime(std::vector& work_time_array) { + std::vector total_time_array; try { FILE* file = fopen("/proc/stat", "r"); fiu_do_on("SystemInfo.getTotalCpuTime.open_proc", file = NULL); @@ -189,8 +189,8 @@ SystemInfo::getTotalCpuTime(std::vector& work_time_array) { return total_time_array; } - uint64_t user = 0, nice = 0, system = 0, idle = 0; - uint64_t iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guestnice = 0; + int64_t user = 0, nice = 0, system = 0, idle = 0; + int64_t iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guestnice = 0; for (int i = 0; i < num_processors_; i++) { char buffer[1024]; @@ -244,16 +244,15 @@ SystemInfo::CPUPercent() { return percent; } -std::vector +std::vector SystemInfo::GPUMemoryTotal() { // get GPU usage percent fiu_do_on("SystemInfo.GPUMemoryTotal.mock", initialized_ = false); if (!initialized_) Init(); - std::vector result; + std::vector result; #ifdef MILVUS_GPU_VERSION - nvmlMemory_t nvmlMemory; for (int i = 0; i < num_device_; ++i) { nvmlDevice_t device; @@ -266,15 +265,14 @@ SystemInfo::GPUMemoryTotal() { return result; } -std::vector +std::vector SystemInfo::GPUTemperature() { fiu_do_on("SystemInfo.GPUTemperature.mock", initialized_ = false); if (!initialized_) Init(); - std::vector result; + std::vector result; #ifdef MILVUS_GPU_VERSION - for (int i = 0; i < num_device_; i++) { nvmlDevice_t device; nvmlDeviceGetHandleByIndex(i, &device); @@ -282,7 +280,6 @@ SystemInfo::GPUTemperature() { nvmlDeviceGetTemperature(device, NVML_TEMPERATURE_GPU, &temp); result.push_back(temp); } - #endif return result; @@ -334,17 +331,16 @@ SystemInfo::CPUTemperature() { return result; } -std::vector +std::vector SystemInfo::GPUMemoryUsed() { // get GPU memory used fiu_do_on("SystemInfo.GPUMemoryUsed.mock", initialized_ = false); if (!initialized_) Init(); - std::vector result; + std::vector result; #ifdef MILVUS_GPU_VERSION - nvmlMemory_t nvmlMemory; for (int i = 0; i < num_device_; ++i) { nvmlDevice_t device; @@ -352,13 +348,12 @@ SystemInfo::GPUMemoryUsed() { nvmlDeviceGetMemoryInfo(device, &nvmlMemory); result.push_back(nvmlMemory.used); } - #endif return result; } -std::pair +std::pair SystemInfo::Octets() { pid_t pid = getpid(); // const std::string filename = "/proc/"+std::to_string(pid)+"/net/netstat"; @@ -387,9 +382,9 @@ SystemInfo::Octets() { std::string inoctets = lastline.substr(inoctets_begin, inoctets_length); std::string outoctets = lastline.substr(outoctets_begin, outoctets_length); - uint64_t inoctets_bytes = std::stoull(inoctets); - uint64_t outoctets_bytes = std::stoull(outoctets); - std::pair res(inoctets_bytes, outoctets_bytes); + int64_t inoctets_bytes = std::stoull(inoctets); + int64_t outoctets_bytes = std::stoull(outoctets); + std::pair res(inoctets_bytes, outoctets_bytes); return res; } @@ -400,8 +395,8 @@ SystemInfo::GetSysInfoJsonStr(std::string& result) { sys_info_map["memory_total"] = std::to_string(GetPhysicalMemory()); sys_info_map["memory_used"] = std::to_string(GetProcessUsedMemory()); - std::vector gpu_mem_total = GPUMemoryTotal(); - std::vector gpu_mem_used = GPUMemoryUsed(); + std::vector gpu_mem_total = GPUMemoryTotal(); + std::vector gpu_mem_used = GPUMemoryUsed(); for (size_t i = 0; i < gpu_mem_total.size(); i++) { std::string key_total = "gpu" + std::to_string(i) + "_memory_total"; std::string key_used = "gpu" + std::to_string(i) + "_memory_used"; diff --git a/core/src/metrics/SystemInfo.h b/core/src/metrics/SystemInfo.h index 25196d9f03..6413ab9149 100644 --- a/core/src/metrics/SystemInfo.h +++ b/core/src/metrics/SystemInfo.h @@ -21,17 +21,17 @@ namespace server { class SystemInfo { private: - uint64_t total_ram_ = 0; + int64_t total_ram_ = 0; clock_t last_cpu_ = clock_t(); clock_t last_sys_cpu_ = clock_t(); clock_t last_user_cpu_ = clock_t(); std::chrono::system_clock::time_point net_time_ = std::chrono::system_clock::now(); - int num_processors_ = 0; - int num_physical_processors_ = 0; + int32_t num_processors_ = 0; + int32_t num_physical_processors_ = 0; // number of GPU uint32_t num_device_ = 0; - uint64_t in_octets_ = 0; - uint64_t out_octets_ = 0; + int64_t in_octets_ = 0; + int64_t out_octets_ = 0; bool initialized_ = false; public: @@ -44,27 +44,27 @@ class SystemInfo { void Init(); - int + int32_t num_processor() const { return num_processors_; } - int + int32_t num_physical_processors() const { return num_physical_processors_; } - uint32_t + int32_t num_device() const { return num_device_; } - uint64_t + int64_t get_inoctets() { return in_octets_; } - uint64_t + int64_t get_octets() { return out_octets_; } @@ -75,12 +75,12 @@ class SystemInfo { } void - set_inoctets(uint64_t value) { + set_inoctets(int64_t value) { in_octets_ = value; } void - set_outoctets(uint64_t value) { + set_outoctets(int64_t value) { out_octets_ = value; } @@ -89,28 +89,28 @@ class SystemInfo { net_time_ = std::chrono::system_clock::now(); } - uint64_t + int64_t ParseLine(char* line); - uint64_t + int64_t GetPhysicalMemory(); - uint64_t + int64_t GetProcessUsedMemory(); double MemoryPercent(); double CPUPercent(); - std::pair + std::pair Octets(); - std::vector + std::vector GPUMemoryTotal(); - std::vector + std::vector GPUMemoryUsed(); std::vector CPUCorePercent(); - std::vector - getTotalCpuTime(std::vector& workTime); - std::vector + std::vector + getTotalCpuTime(std::vector& workTime); + std::vector GPUTemperature(); std::vector CPUTemperature(); diff --git a/core/src/metrics/prometheus/PrometheusMetrics.cpp b/core/src/metrics/prometheus/PrometheusMetrics.cpp index 1fa4a80205..2fba649040 100644 --- a/core/src/metrics/prometheus/PrometheusMetrics.cpp +++ b/core/src/metrics/prometheus/PrometheusMetrics.cpp @@ -93,8 +93,8 @@ PrometheusMetrics::GPUPercentGaugeSet() { } int numDevice = server::SystemInfo::GetInstance().num_device(); - std::vector used_total = server::SystemInfo::GetInstance().GPUMemoryTotal(); - std::vector used_memory = server::SystemInfo::GetInstance().GPUMemoryUsed(); + std::vector used_total = server::SystemInfo::GetInstance().GPUMemoryTotal(); + std::vector used_memory = server::SystemInfo::GetInstance().GPUMemoryUsed(); for (int i = 0; i < numDevice; ++i) { prometheus::Gauge& GPU_percent = GPU_percent_.Add({{"DeviceNum", std::to_string(i)}}); @@ -109,13 +109,13 @@ PrometheusMetrics::GPUMemoryUsageGaugeSet() { return; } - std::vector values = server::SystemInfo::GetInstance().GPUMemoryUsed(); - constexpr uint64_t MtoB = 1024 * 1024; + std::vector values = server::SystemInfo::GetInstance().GPUMemoryUsed(); + constexpr int64_t MB = 1024 * 1024; int numDevice = server::SystemInfo::GetInstance().num_device(); for (int i = 0; i < numDevice; ++i) { prometheus::Gauge& GPU_memory = GPU_memory_usage_.Add({{"DeviceNum", std::to_string(i)}}); - GPU_memory.Set(values[i] / MtoB); + GPU_memory.Set(values[i] / MB); } } @@ -216,7 +216,7 @@ PrometheusMetrics::GPUTemperature() { return; } - std::vector GPU_temperatures = server::SystemInfo::GetInstance().GPUTemperature(); + std::vector GPU_temperatures = server::SystemInfo::GetInstance().GPUTemperature(); for (int i = 0; i < GPU_temperatures.size(); ++i) { prometheus::Gauge& gpu_temp = GPU_temperature_.Add({{"GPU", std::to_string(i)}}); diff --git a/core/src/server/web_impl/handler/WebRequestHandler.cpp b/core/src/server/web_impl/handler/WebRequestHandler.cpp index 06a8dde88c..6dc3140948 100644 --- a/core/src/server/web_impl/handler/WebRequestHandler.cpp +++ b/core/src/server/web_impl/handler/WebRequestHandler.cpp @@ -819,7 +819,7 @@ WebRequestHandler::GetDevices(DevicesDto::ObjectWrapper& devices_dto) { #ifdef MILVUS_GPU_VERSION size_t count = system_info.num_device(); - std::vector device_mems = system_info.GPUMemoryTotal(); + std::vector device_mems = system_info.GPUMemoryTotal(); if (count != device_mems.size()) { RETURN_STATUS_DTO(UNEXPECTED_ERROR, "Can't obtain GPU info");