未验证 提交 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)
add_compile_definitions("MILVUS_WITH_PROMETHEUS")
endif ()
message("MILVUS_ENABLE_PROFILING = ${MILVUS_ENABLE_PROFILING}")
if (MILVUS_ENABLE_PROFILING STREQUAL "ON")
ADD_DEFINITIONS(-DMILVUS_ENABLE_PROFILING)
endif()
if (MILVUS_WITH_FIU)
add_compile_definitions("FIU_ENABLE")
endif ()
......
......@@ -75,10 +75,6 @@ DeleteByDateRequest::OnExecute() {
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);
fiu_do_on("DeleteByDateRequest.OnExecute.drop_table_fail",
status = Status(milvus::SERVER_UNEXPECTED_ERROR, ""));
......
......@@ -11,6 +11,7 @@
#include "server/delivery/request/InsertRequest.h"
#include "server/DBWrapper.h"
#include "utils/CommonUtil.h"
#include "utils/Log.h"
#include "utils/TimeRecorder.h"
#include "utils/ValidationUtil.h"
......@@ -19,6 +20,9 @@
#include <memory>
#include <string>
#include <vector>
#ifdef MILVUS_ENABLE_PROFILING
#include <gperftools/profiler.h>
#endif
namespace milvus {
namespace server {
......@@ -101,8 +105,7 @@ InsertRequest::OnExecute() {
rc.RecordSection("check validation");
#ifdef MILVUS_ENABLE_PROFILING
std::string fname =
"/tmp/insert_" + std::to_string(this->insert_param_->row_record_array_size()) + ".profiling";
std::string fname = "/tmp/insert_" + CommonUtil::GetCurrentTimeStr() + ".profiling";
ProfilerStart(fname.c_str());
#endif
// step 4: some metric type doesn't support float vectors
......
......@@ -11,12 +11,16 @@
#include "server/delivery/request/SearchRequest.h"
#include "server/DBWrapper.h"
#include "utils/CommonUtil.h"
#include "utils/Log.h"
#include "utils/TimeRecorder.h"
#include "utils/ValidationUtil.h"
#include <fiu-local.h>
#include <memory>
#ifdef MILVUS_ENABLE_PROFILING
#include <gperftools/profiler.h>
#endif
namespace milvus {
namespace server {
......@@ -134,8 +138,7 @@ SearchRequest::OnExecute() {
engine::ResultDistances result_distances;
#ifdef MILVUS_ENABLE_PROFILING
std::string fname =
"/tmp/search_nq_" + std::to_string(this->search_param_->query_record_array_size()) + ".profiling";
std::string fname = "/tmp/search_" + CommonUtil::GetCurrentTimeStr() + ".profiling";
ProfilerStart(fname.c_str());
#endif
......
......@@ -228,6 +228,22 @@ CommonUtil::ConvertTime(tm time_struct, time_t& time_integer) {
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
CommonUtil::EraseFromCache(const std::string& item_key) {
if (item_key.empty()) {
......
......@@ -51,6 +51,9 @@ class CommonUtil {
static void
ConvertTime(tm time_struct, time_t& time_integer);
static std::string
GetCurrentTimeStr();
static void
EraseFromCache(const std::string& item_key);
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册