Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
2fec3cc3
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
2fec3cc3
编写于
9月 17, 2021
作者:
S
ShiningZhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add log of cost time
上级
11f64896
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
112 addition
and
74 deletion
+112
-74
core/pdcodegen/src/pdcodegen.cpp
core/pdcodegen/src/pdcodegen.cpp
+112
-74
未找到文件。
core/pdcodegen/src/pdcodegen.cpp
浏览文件 @
2fec3cc3
...
...
@@ -276,43 +276,63 @@ class PdsCodeGenerator : public CodeGenerator {
"output_name"
,
google
::
protobuf
::
dots_to_colons
(
m
->
output_type
()
->
full_name
()));
if
(
m
->
name
()
==
"inference"
)
{
std
::
string
inference_body
=
""
;
inference_body
+=
" brpc::ClosureGuard done_guard(done);
\n
"
;
inference_body
+=
" brpc::Controller* cntl =
\n
"
;
inference_body
+=
" static_cast<brpc::Controller*>(cntl_base);
\n
"
;
inference_body
+=
" cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP);
\n
"
;
inference_body
+=
" uint64_t log_id = request->log_id();
\n
"
;
inference_body
+=
" cntl->set_log_id(log_id);
\n
"
;
inference_body
+=
" ::baidu::paddle_serving::predictor::InferService* svr =
\n
"
;
inference_body
+=
" "
;
inference_body
+=
"::baidu::paddle_serving::predictor::InferServiceManager::instance("
;
inference_body
+=
").item(
\"
$service$
\"
);
\n
"
;
inference_body
+=
" if (svr == NULL) {
\n
"
;
inference_body
+=
" LOG(ERROR) <<
\"
(logid=
\"
<< log_id <<
\"
) Not found service: "
;
inference_body
+=
"$service$
\"
;
\n
"
;
inference_body
+=
" cntl->SetFailed(404,
\"
Not found service: $service$
\"
);
\n
"
;
inference_body
+=
" return ;
\n
"
;
inference_body
+=
" }
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
;
inference_body
+=
"remote_side=\[
\"
<< cntl->remote_side() << "
;
// NOLINT
inference_body
+=
"
\"
\]
\"
;
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
;
inference_body
+=
"local_side=\[
\"
<< cntl->local_side() << "
;
// NOLINT
inference_body
+=
"
\"
\]
\"
;
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
;
inference_body
+=
"service_name=\[
\"
<<
\"
$name$
\"
<<
\"
\]
\"
;
\n
"
;
// NOLINT
inference_body
+=
" int err_code = svr->inference(request, response, log_id);
\n
"
;
inference_body
+=
" if (err_code != 0) {
\n
"
;
inference_body
+=
" LOG(WARNING)
\n
"
;
inference_body
+=
" <<
\"
(logid=
\"
<< log_id <<
\"
) Failed call "
;
inference_body
+=
"inferservice[$name$], name[$service$]
\"\n
"
;
inference_body
+=
" <<
\"
, error_code:
\"
<< err_code;
\n
"
;
inference_body
+=
" cntl->SetFailed(err_code,
\"
InferService inference "
;
inference_body
+=
"failed!
\"
);
\n
"
;
inference_body
+=
" }
\n
"
;
inference_body
+=
" gettimeofday(&tv, NULL);
\n
"
;
inference_body
+=
" long end = tv.tv_sec * 1000000 + tv.tv_usec;
\n
"
;
if
(
service_name
==
"GeneralModelService"
)
{
inference_body
+=
" std::ostringstream oss;
\n
"
;
inference_body
+=
" oss <<
\"
[serving]
\"\n
"
;
inference_body
+=
" <<
\"
logid=
\"
<< log_id <<
\"
,
\"
;
\n
"
;
inference_body
+=
" int op_num = response->profile_time_size() / 2;
\n
"
;
inference_body
+=
" for (int i = 0; i < op_num; ++i) {
\n
"
;
inference_body
+=
" double t = (response->profile_time(i * 2 + 1)
\n
"
;
inference_body
+=
" - response->profile_time(i * 2)) / 1000.0;
\n
"
;
inference_body
+=
" oss <<
\"
op
\"
<< i <<
\"
=
\"
<< t <<
\"
ms,
\"
;
\n
"
;
inference_body
+=
" }
\n
"
;
inference_body
+=
" double total_time = (end - start) / 1000.0;
\n
"
;
inference_body
+=
" oss <<
\"
cost=
\"
<< total_time <<
\"
ms.
\"
;
\n
"
;
inference_body
+=
" // flush notice log
\n
"
;
inference_body
+=
" LOG(INFO) << oss.str();
\n
"
;
}
else
{
inference_body
+=
" // flush notice log
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) tc=\[
\"
<< (end - "
;
// NOLINT
inference_body
+=
"start) <<
\"
\]
\"
;
\n
"
;
}
printer
->
Print
(
" baidu::rpc::ClosureGuard done_guard(done);
\n
"
" baidu::rpc::Controller* cntl =
\n
"
" static_cast<baidu::rpc::Controller*>(cntl_base);
\n
"
" cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP);
\n
"
" uint64_t log_id = request->log_id();
\n
"
" cntl->set_log_id(log_id);
\n
"
" ::baidu::paddle_serving::predictor::InferService* svr =
\n
"
" "
"::baidu::paddle_serving::predictor::InferServiceManager::instance("
").item(
\"
$service$
\"
);
\n
"
" if (svr == NULL) {
\n
"
" LOG(ERROR) <<
\"
(logid=
\"
<< log_id <<
\"
) Not found service: "
"$service$
\"
;
\n
"
" cntl->SetFailed(404,
\"
Not found service: $service$
\"
);
\n
"
" return ;
\n
"
" }
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) remote_side=\[
\"
"
// NOLINT
"<< cntl->remote_side() <<
\"
\]
\"
;
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) local_side=\[
\"
"
// NOLINT
"<< cntl->local_side() <<
\"
\]
\"
;
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) service_name=\[
\"
"
// NOLINT
"<<
\"
$name$
\"
<<
\"
\]
\"
;
\n
"
" int err_code = svr->inference(request, response, log_id);
\n
"
" if (err_code != 0) {
\n
"
" LOG(WARNING)
\n
"
" <<
\"
(logid=
\"
<< log_id <<
\"
) Failed call "
"inferservice[$name$], name[$service$]
\"\n
"
" <<
\"
, error_code:
\"
<< err_code;
\n
"
" cntl->SetFailed(err_code,
\"
InferService inference "
"failed!
\"
);
\n
"
" }
\n
"
" gettimeofday(&tv, NULL);
\n
"
" long end = tv.tv_sec * 1000000 + tv.tv_usec;
\n
"
" // flush notice log
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) tc=\[
\"
<< (end - "
// NOLINT
"start) <<
\"
\]
\"
;
\n
"
,
// NOLINT
inference_body
.
c_str
(),
"name"
,
class_name
,
"service"
,
...
...
@@ -1021,45 +1041,63 @@ class PdsCodeGenerator : public CodeGenerator {
"output_name"
,
google
::
protobuf
::
dots_to_colons
(
m
->
output_type
()
->
full_name
()));
if
(
m
->
name
()
==
"inference"
)
{
std
::
string
inference_body
=
""
;
inference_body
+=
" brpc::ClosureGuard done_guard(done);
\n
"
;
inference_body
+=
" brpc::Controller* cntl =
\n
"
;
inference_body
+=
" static_cast<brpc::Controller*>(cntl_base);
\n
"
;
inference_body
+=
" cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP);
\n
"
;
inference_body
+=
" uint64_t log_id = request->log_id();
\n
"
;
inference_body
+=
" cntl->set_log_id(log_id);
\n
"
;
inference_body
+=
" ::baidu::paddle_serving::predictor::InferService* svr =
\n
"
;
inference_body
+=
" "
;
inference_body
+=
"::baidu::paddle_serving::predictor::InferServiceManager::instance("
;
inference_body
+=
").item(
\"
$service$
\"
);
\n
"
;
inference_body
+=
" if (svr == NULL) {
\n
"
;
inference_body
+=
" LOG(ERROR) <<
\"
(logid=
\"
<< log_id <<
\"
) Not found service: "
;
inference_body
+=
"$service$
\"
;
\n
"
;
inference_body
+=
" cntl->SetFailed(404,
\"
Not found service: $service$
\"
);
\n
"
;
inference_body
+=
" return ;
\n
"
;
inference_body
+=
" }
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
;
inference_body
+=
"remote_side=\[
\"
<< cntl->remote_side() << "
;
// NOLINT
inference_body
+=
"
\"
\]
\"
;
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
;
inference_body
+=
"local_side=\[
\"
<< cntl->local_side() << "
;
// NOLINT
inference_body
+=
"
\"
\]
\"
;
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
;
inference_body
+=
"service_name=\[
\"
<<
\"
$name$
\"
<<
\"
\]
\"
;
\n
"
;
// NOLINT
inference_body
+=
" int err_code = svr->inference(request, response, log_id);
\n
"
;
inference_body
+=
" if (err_code != 0) {
\n
"
;
inference_body
+=
" LOG(WARNING)
\n
"
;
inference_body
+=
" <<
\"
(logid=
\"
<< log_id <<
\"
) Failed call "
;
inference_body
+=
"inferservice[$name$], name[$service$]
\"\n
"
;
inference_body
+=
" <<
\"
, error_code:
\"
<< err_code;
\n
"
;
inference_body
+=
" cntl->SetFailed(err_code,
\"
InferService inference "
;
inference_body
+=
"failed!
\"
);
\n
"
;
inference_body
+=
" }
\n
"
;
inference_body
+=
" gettimeofday(&tv, NULL);
\n
"
;
inference_body
+=
" long end = tv.tv_sec * 1000000 + tv.tv_usec;
\n
"
;
if
(
service_name
==
"GeneralModelService"
)
{
inference_body
+=
" std::ostringstream oss;
\n
"
;
inference_body
+=
" oss <<
\"
[serving]
\"\n
"
;
inference_body
+=
" <<
\"
logid=
\"
<< log_id <<
\"
,
\"
;
\n
"
;
inference_body
+=
" int op_num = response->profile_time_size() / 2;
\n
"
;
inference_body
+=
" for (int i = 0; i < op_num; ++i) {
\n
"
;
inference_body
+=
" double t = (response->profile_time(i * 2 + 1)
\n
"
;
inference_body
+=
" - response->profile_time(i * 2)) / 1000.0;
\n
"
;
inference_body
+=
" oss <<
\"
op
\"
<< i <<
\"
=
\"
<< t <<
\"
ms,
\"
;
\n
"
;
inference_body
+=
" }
\n
"
;
inference_body
+=
" double total_time = (end - start) / 1000.0;
\n
"
;
inference_body
+=
" oss <<
\"
cost=
\"
<< total_time <<
\"
ms.
\"
;
\n
"
;
inference_body
+=
" // flush notice log
\n
"
;
inference_body
+=
" LOG(INFO) << oss.str();
\n
"
;
}
else
{
inference_body
+=
" // flush notice log
\n
"
;
inference_body
+=
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) tc=\[
\"
<< (end - "
;
// NOLINT
inference_body
+=
"start) <<
\"
\]
\"
;
\n
"
;
}
printer
->
Print
(
" brpc::ClosureGuard done_guard(done);
\n
"
" brpc::Controller* cntl =
\n
"
" static_cast<brpc::Controller*>(cntl_base);
\n
"
" cntl->set_response_compress_type(brpc::COMPRESS_TYPE_GZIP);
\n
"
" uint64_t log_id = request->log_id();
\n
"
" cntl->set_log_id(log_id);
\n
"
" ::baidu::paddle_serving::predictor::InferService* svr =
\n
"
" "
"::baidu::paddle_serving::predictor::InferServiceManager::instance("
").item(
\"
$service$
\"
);
\n
"
" if (svr == NULL) {
\n
"
" LOG(ERROR) <<
\"
(logid=
\"
<< log_id <<
\"
) Not found service: "
"$service$
\"
;
\n
"
" cntl->SetFailed(404,
\"
Not found service: $service$
\"
);
\n
"
" return ;
\n
"
" }
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
"remote_side=\[
\"
<< cntl->remote_side() << "
// NOLINT
"
\"
\]
\"
;
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
"local_side=\[
\"
<< cntl->local_side() << "
// NOLINT
"
\"
\]
\"
;
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) "
"service_name=\[
\"
<<
\"
$name$
\"
<<
\"
\]
\"
;
\n
"
// NOLINT
" int err_code = svr->inference(request, response, log_id);
\n
"
" if (err_code != 0) {
\n
"
" LOG(WARNING)
\n
"
" <<
\"
(logid=
\"
<< log_id <<
\"
) Failed call "
"inferservice[$name$], name[$service$]
\"\n
"
" <<
\"
, error_code:
\"
<< err_code;
\n
"
" cntl->SetFailed(err_code,
\"
InferService inference "
"failed!
\"
);
\n
"
" }
\n
"
" gettimeofday(&tv, NULL);
\n
"
" long end = tv.tv_sec * 1000000 + tv.tv_usec;
\n
"
" // flush notice log
\n
"
" LOG(INFO) <<
\"
(logid=
\"
<< log_id <<
\"
) tc=\[
\"
<< (end - "
// NOLINT
"start) <<
\"
\]
\"
;
\n
"
,
// NOLINT
inference_body
.
c_str
(),
"name"
,
class_name
,
"service"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录