mirror of https://github.com/milvus-io/milvus.git
support CPU profiling (#1251)
* #1250 support CPU profiling Signed-off-by: yudong.cai <yudong.cai@zilliz.com> * #1250 fix code coverage Signed-off-by: yudong.cai <yudong.cai@zilliz.com>pull/1275/head^2
parent
e9cc51dbb8
commit
b62369fafd
|
@ -171,6 +171,11 @@ if (MILVUS_WITH_PROMETHEUS)
|
||||||
add_compile_definitions("MILVUS_WITH_PROMETHEUS")
|
add_compile_definitions("MILVUS_WITH_PROMETHEUS")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
message("MILVUS_ENABLE_PROFILING = ${MILVUS_ENABLE_PROFILING}")
|
||||||
|
if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
|
||||||
|
ADD_DEFINITIONS(-DMILVUS_ENABLE_PROFILING)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (MILVUS_WITH_FIU)
|
if (MILVUS_WITH_FIU)
|
||||||
add_compile_definitions("FIU_ENABLE")
|
add_compile_definitions("FIU_ENABLE")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
|
@ -75,10 +75,6 @@ DeleteByDateRequest::OnExecute() {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MILVUS_ENABLE_PROFILING
|
|
||||||
std::string fname = "/tmp/search_nq_" + this->delete_by_range_param_->table_name() + ".profiling";
|
|
||||||
ProfilerStart(fname.c_str());
|
|
||||||
#endif
|
|
||||||
status = DBWrapper::DB()->DropTable(table_name_, dates);
|
status = DBWrapper::DB()->DropTable(table_name_, dates);
|
||||||
fiu_do_on("DeleteByDateRequest.OnExecute.drop_table_fail",
|
fiu_do_on("DeleteByDateRequest.OnExecute.drop_table_fail",
|
||||||
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
#include "server/delivery/request/InsertRequest.h"
|
#include "server/delivery/request/InsertRequest.h"
|
||||||
#include "server/DBWrapper.h"
|
#include "server/DBWrapper.h"
|
||||||
|
#include "utils/CommonUtil.h"
|
||||||
#include "utils/Log.h"
|
#include "utils/Log.h"
|
||||||
#include "utils/TimeRecorder.h"
|
#include "utils/TimeRecorder.h"
|
||||||
#include "utils/ValidationUtil.h"
|
#include "utils/ValidationUtil.h"
|
||||||
|
@ -19,6 +20,9 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#ifdef MILVUS_ENABLE_PROFILING
|
||||||
|
#include <gperftools/profiler.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
@ -101,8 +105,7 @@ InsertRequest::OnExecute() {
|
||||||
rc.RecordSection("check validation");
|
rc.RecordSection("check validation");
|
||||||
|
|
||||||
#ifdef MILVUS_ENABLE_PROFILING
|
#ifdef MILVUS_ENABLE_PROFILING
|
||||||
std::string fname =
|
std::string fname = "/tmp/insert_" + CommonUtil::GetCurrentTimeStr() + ".profiling";
|
||||||
"/tmp/insert_" + std::to_string(this->insert_param_->row_record_array_size()) + ".profiling";
|
|
||||||
ProfilerStart(fname.c_str());
|
ProfilerStart(fname.c_str());
|
||||||
#endif
|
#endif
|
||||||
// step 4: some metric type doesn't support float vectors
|
// step 4: some metric type doesn't support float vectors
|
||||||
|
|
|
@ -11,12 +11,16 @@
|
||||||
|
|
||||||
#include "server/delivery/request/SearchRequest.h"
|
#include "server/delivery/request/SearchRequest.h"
|
||||||
#include "server/DBWrapper.h"
|
#include "server/DBWrapper.h"
|
||||||
|
#include "utils/CommonUtil.h"
|
||||||
#include "utils/Log.h"
|
#include "utils/Log.h"
|
||||||
#include "utils/TimeRecorder.h"
|
#include "utils/TimeRecorder.h"
|
||||||
#include "utils/ValidationUtil.h"
|
#include "utils/ValidationUtil.h"
|
||||||
|
|
||||||
#include <fiu-local.h>
|
#include <fiu-local.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#ifdef MILVUS_ENABLE_PROFILING
|
||||||
|
#include <gperftools/profiler.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace milvus {
|
namespace milvus {
|
||||||
namespace server {
|
namespace server {
|
||||||
|
@ -134,8 +138,7 @@ SearchRequest::OnExecute() {
|
||||||
engine::ResultDistances result_distances;
|
engine::ResultDistances result_distances;
|
||||||
|
|
||||||
#ifdef MILVUS_ENABLE_PROFILING
|
#ifdef MILVUS_ENABLE_PROFILING
|
||||||
std::string fname =
|
std::string fname = "/tmp/search_" + CommonUtil::GetCurrentTimeStr() + ".profiling";
|
||||||
"/tmp/search_nq_" + std::to_string(this->search_param_->query_record_array_size()) + ".profiling";
|
|
||||||
ProfilerStart(fname.c_str());
|
ProfilerStart(fname.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -228,6 +228,22 @@ CommonUtil::ConvertTime(tm time_struct, time_t& time_integer) {
|
||||||
time_integer = mktime(&time_struct);
|
time_integer = mktime(&time_struct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef MILVUS_ENABLE_PROFILING
|
||||||
|
std::string
|
||||||
|
CommonUtil::GetCurrentTimeStr() {
|
||||||
|
time_t tt;
|
||||||
|
time(&tt);
|
||||||
|
tt = tt + 8 * 60;
|
||||||
|
tm t;
|
||||||
|
gmtime_r(&tt, &t);
|
||||||
|
|
||||||
|
std::string str = std::to_string(t.tm_year + 1900) + "_" + std::to_string(t.tm_mon + 1) + "_" +
|
||||||
|
std::to_string(t.tm_mday) + "_" + std::to_string(t.tm_hour) + "_" + std::to_string(t.tm_min) +
|
||||||
|
"_" + std::to_string(t.tm_sec);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
CommonUtil::EraseFromCache(const std::string& item_key) {
|
CommonUtil::EraseFromCache(const std::string& item_key) {
|
||||||
if (item_key.empty()) {
|
if (item_key.empty()) {
|
||||||
|
|
|
@ -51,6 +51,9 @@ class CommonUtil {
|
||||||
static void
|
static void
|
||||||
ConvertTime(tm time_struct, time_t& time_integer);
|
ConvertTime(tm time_struct, time_t& time_integer);
|
||||||
|
|
||||||
|
static std::string
|
||||||
|
GetCurrentTimeStr();
|
||||||
|
|
||||||
static void
|
static void
|
||||||
EraseFromCache(const std::string& item_key);
|
EraseFromCache(const std::string& item_key);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue