未验证 提交 b62369fa 编写于 作者: C Cai Yudong 提交者: GitHub

support CPU profiling (#1251)

* #1250 support CPU profiling
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>

* #1250 fix code coverage
Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 e9cc51db
...@@ -171,6 +171,11 @@ if (MILVUS_WITH_PROMETHEUS) ...@@ -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() { ...@@ -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 @@ ...@@ -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 @@ ...@@ -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() { ...@@ -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 @@ ...@@ -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() { ...@@ -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) { ...@@ -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 { ...@@ -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);
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册