mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-30 07:25:37 +08:00
* #2370 clean compile warning Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * update changelog Signed-off-by: yudong.cai <yudong.cai@zilliz.com>
This commit is contained in:
parent
42f751047e
commit
b9e8acb5b2
@ -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
|
||||
|
||||
|
||||
4
core/src/cache/Cache.inl
vendored
4
core/src/cache/Cache.inl
vendored
@ -16,9 +16,9 @@ constexpr double DEFAULT_THRESHOLD_PERCENT = 0.7;
|
||||
|
||||
template <typename ItemObj>
|
||||
Cache<ItemObj>::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) {
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -47,7 +47,7 @@ SimpleIDGenerator::NextIDNumbers(size_t n, IDNumbers& ids) {
|
||||
auto micros = std::chrono::duration_cast<std::chrono::microseconds>(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);
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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<std::string, int64_t>;
|
||||
|
||||
@ -59,7 +59,5 @@ struct Entity {
|
||||
using File2ErrArray = std::map<std::string, std::vector<std::string>>;
|
||||
using Table2FileErr = std::map<std::string, File2ErrArray>;
|
||||
|
||||
static const char* DEFAULT_PARTITON_TAG = "_default";
|
||||
|
||||
} // namespace engine
|
||||
} // namespace milvus
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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<double>(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
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -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]);
|
||||
}
|
||||
|
||||
|
||||
@ -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();
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
27
core/src/db/meta/Meta.cpp
Normal file
27
core/src/db/meta/Meta.cpp
Normal file
@ -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
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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; \
|
||||
|
||||
2
core/src/index/thirdparty/hnswlib/hnswalg.h
vendored
2
core/src/index/thirdparty/hnswlib/hnswalg.h
vendored
@ -618,8 +618,6 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
|
||||
}
|
||||
|
||||
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_);
|
||||
|
||||
@ -85,7 +85,7 @@ SystemInfo::Init() {
|
||||
|
||||
// initialize network traffic information
|
||||
try {
|
||||
std::pair<uint64_t, uint64_t> in_and_out_octets = Octets();
|
||||
std::pair<int64_t, int64_t> 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<uint64_t>(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<double>
|
||||
SystemInfo::CPUCorePercent() {
|
||||
std::vector<uint64_t> prev_work_time_array;
|
||||
std::vector<uint64_t> prev_total_time_array = getTotalCpuTime(prev_work_time_array);
|
||||
std::vector<int64_t> prev_work_time_array;
|
||||
std::vector<int64_t> prev_total_time_array = getTotalCpuTime(prev_work_time_array);
|
||||
usleep(100000);
|
||||
std::vector<uint64_t> cur_work_time_array;
|
||||
std::vector<uint64_t> cur_total_time_array = getTotalCpuTime(cur_work_time_array);
|
||||
std::vector<int64_t> cur_work_time_array;
|
||||
std::vector<int64_t> cur_total_time_array = getTotalCpuTime(cur_work_time_array);
|
||||
|
||||
std::vector<double> 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<uint64_t>
|
||||
SystemInfo::getTotalCpuTime(std::vector<uint64_t>& work_time_array) {
|
||||
std::vector<uint64_t> total_time_array;
|
||||
std::vector<int64_t>
|
||||
SystemInfo::getTotalCpuTime(std::vector<int64_t>& work_time_array) {
|
||||
std::vector<int64_t> 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<uint64_t>& 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<uint64_t>
|
||||
std::vector<int64_t>
|
||||
SystemInfo::GPUMemoryTotal() {
|
||||
// get GPU usage percent
|
||||
fiu_do_on("SystemInfo.GPUMemoryTotal.mock", initialized_ = false);
|
||||
if (!initialized_)
|
||||
Init();
|
||||
std::vector<uint64_t> result;
|
||||
std::vector<int64_t> 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<uint64_t>
|
||||
std::vector<int64_t>
|
||||
SystemInfo::GPUTemperature() {
|
||||
fiu_do_on("SystemInfo.GPUTemperature.mock", initialized_ = false);
|
||||
if (!initialized_)
|
||||
Init();
|
||||
std::vector<uint64_t> result;
|
||||
std::vector<int64_t> 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<uint64_t>
|
||||
std::vector<int64_t>
|
||||
SystemInfo::GPUMemoryUsed() {
|
||||
// get GPU memory used
|
||||
fiu_do_on("SystemInfo.GPUMemoryUsed.mock", initialized_ = false);
|
||||
if (!initialized_)
|
||||
Init();
|
||||
|
||||
std::vector<uint64_t> result;
|
||||
std::vector<int64_t> 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<uint64_t, uint64_t>
|
||||
std::pair<int64_t, int64_t>
|
||||
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<uint64_t, uint64_t> res(inoctets_bytes, outoctets_bytes);
|
||||
int64_t inoctets_bytes = std::stoull(inoctets);
|
||||
int64_t outoctets_bytes = std::stoull(outoctets);
|
||||
std::pair<int64_t, int64_t> 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<uint64_t> gpu_mem_total = GPUMemoryTotal();
|
||||
std::vector<uint64_t> gpu_mem_used = GPUMemoryUsed();
|
||||
std::vector<int64_t> gpu_mem_total = GPUMemoryTotal();
|
||||
std::vector<int64_t> 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";
|
||||
|
||||
@ -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<uint64_t, uint64_t>
|
||||
std::pair<int64_t, int64_t>
|
||||
Octets();
|
||||
std::vector<uint64_t>
|
||||
std::vector<int64_t>
|
||||
GPUMemoryTotal();
|
||||
std::vector<uint64_t>
|
||||
std::vector<int64_t>
|
||||
GPUMemoryUsed();
|
||||
|
||||
std::vector<double>
|
||||
CPUCorePercent();
|
||||
std::vector<uint64_t>
|
||||
getTotalCpuTime(std::vector<uint64_t>& workTime);
|
||||
std::vector<uint64_t>
|
||||
std::vector<int64_t>
|
||||
getTotalCpuTime(std::vector<int64_t>& workTime);
|
||||
std::vector<int64_t>
|
||||
GPUTemperature();
|
||||
std::vector<float>
|
||||
CPUTemperature();
|
||||
|
||||
@ -93,8 +93,8 @@ PrometheusMetrics::GPUPercentGaugeSet() {
|
||||
}
|
||||
|
||||
int numDevice = server::SystemInfo::GetInstance().num_device();
|
||||
std::vector<uint64_t> used_total = server::SystemInfo::GetInstance().GPUMemoryTotal();
|
||||
std::vector<uint64_t> used_memory = server::SystemInfo::GetInstance().GPUMemoryUsed();
|
||||
std::vector<int64_t> used_total = server::SystemInfo::GetInstance().GPUMemoryTotal();
|
||||
std::vector<int64_t> 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<uint64_t> values = server::SystemInfo::GetInstance().GPUMemoryUsed();
|
||||
constexpr uint64_t MtoB = 1024 * 1024;
|
||||
std::vector<int64_t> 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<uint64_t> GPU_temperatures = server::SystemInfo::GetInstance().GPUTemperature();
|
||||
std::vector<int64_t> 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)}});
|
||||
|
||||
@ -819,7 +819,7 @@ WebRequestHandler::GetDevices(DevicesDto::ObjectWrapper& devices_dto) {
|
||||
|
||||
#ifdef MILVUS_GPU_VERSION
|
||||
size_t count = system_info.num_device();
|
||||
std::vector<uint64_t> device_mems = system_info.GPUMemoryTotal();
|
||||
std::vector<int64_t> device_mems = system_info.GPUMemoryTotal();
|
||||
|
||||
if (count != device_mems.size()) {
|
||||
RETURN_STATUS_DTO(UNEXPECTED_ERROR, "Can't obtain GPU info");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user