Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
be0806cf
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
185
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
be0806cf
编写于
6月 23, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
差异文件
merge code
上级
371eb508
f3f9c4fb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
52 addition
and
38 deletion
+52
-38
python/examples/util/timeline_trace.py
python/examples/util/timeline_trace.py
+8
-2
python/paddle_serving_server_gpu/pyserver.py
python/paddle_serving_server_gpu/pyserver.py
+25
-22
python/pipeline/operator.py
python/pipeline/operator.py
+19
-14
未找到文件。
python/examples/util/timeline_trace.py
浏览文件 @
be0806cf
...
@@ -16,10 +16,16 @@ def prase(pid_str, time_str, counter):
...
@@ -16,10 +16,16 @@ def prase(pid_str, time_str, counter):
if
len
(
name_list
)
==
2
:
if
len
(
name_list
)
==
2
:
name
=
name_list
[
0
]
name
=
name_list
[
0
]
else
:
else
:
name
=
name_list
[
0
]
+
"_"
+
name_list
[
1
]
name
=
"_"
.
join
(
name_list
[:
-
1
])
name_list
=
name
.
split
(
"#"
)
if
len
(
name_list
)
>
1
:
tid
=
name_list
[
-
1
]
name
=
"#"
.
join
(
name_list
[:
-
1
])
else
:
tid
=
0
event_dict
=
{}
event_dict
=
{}
event_dict
[
"name"
]
=
name
event_dict
[
"name"
]
=
name
event_dict
[
"tid"
]
=
0
event_dict
[
"tid"
]
=
tid
event_dict
[
"pid"
]
=
pid
event_dict
[
"pid"
]
=
pid
event_dict
[
"ts"
]
=
ts
event_dict
[
"ts"
]
=
ts
event_dict
[
"ph"
]
=
ph
event_dict
[
"ph"
]
=
ph
...
...
python/paddle_serving_server_gpu/pyserver.py
浏览文件 @
be0806cf
...
@@ -813,10 +813,11 @@ class Op(object):
...
@@ -813,10 +813,11 @@ class Op(object):
op_info_prefix
=
"[{}|{}]"
.
format
(
self
.
name
,
concurrency_idx
)
op_info_prefix
=
"[{}|{}]"
.
format
(
self
.
name
,
concurrency_idx
)
log
=
self
.
_get_log_func
(
op_info_prefix
)
log
=
self
.
_get_log_func
(
op_info_prefix
)
self
.
_is_run
=
True
self
.
_is_run
=
True
tid
=
threading
.
current_thread
().
ident
while
self
.
_is_run
:
while
self
.
_is_run
:
_profiler
.
record
(
"{}-get
_0"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-get
#{}_0"
.
format
(
op_info_prefix
,
tid
))
channeldata
=
input_channel
.
front
(
self
.
name
)
channeldata
=
input_channel
.
front
(
self
.
name
)
_profiler
.
record
(
"{}-get
_1"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-get
#{}_1"
.
format
(
op_info_prefix
,
tid
))
logging
.
debug
(
log
(
"input_data: {}"
.
format
(
channeldata
)))
logging
.
debug
(
log
(
"input_data: {}"
.
format
(
channeldata
)))
data_id
,
error_channeldata
=
self
.
_parse_channeldata
(
channeldata
)
data_id
,
error_channeldata
=
self
.
_parse_channeldata
(
channeldata
)
...
@@ -829,9 +830,9 @@ class Op(object):
...
@@ -829,9 +830,9 @@ class Op(object):
# preprecess
# preprecess
try
:
try
:
_profiler
.
record
(
"{}-prep
_0"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-prep
#{}_0"
.
format
(
op_info_prefix
,
tid
))
preped_data
=
self
.
preprocess
(
channeldata
)
preped_data
=
self
.
preprocess
(
channeldata
)
_profiler
.
record
(
"{}-prep
_1"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-prep
#{}_1"
.
format
(
op_info_prefix
,
tid
))
except
NotImplementedError
as
e
:
except
NotImplementedError
as
e
:
# preprocess function not implemented
# preprocess function not implemented
error_info
=
log
(
e
)
error_info
=
log
(
e
)
...
@@ -869,7 +870,7 @@ class Op(object):
...
@@ -869,7 +870,7 @@ class Op(object):
midped_data
=
None
midped_data
=
None
if
self
.
with_serving
:
if
self
.
with_serving
:
ecode
=
ChannelDataEcode
.
OK
.
value
ecode
=
ChannelDataEcode
.
OK
.
value
_profiler
.
record
(
"{}-midp
_0"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-midp
#{}_0"
.
format
(
op_info_prefix
,
tid
))
if
self
.
_timeout
<=
0
:
if
self
.
_timeout
<=
0
:
try
:
try
:
midped_data
=
self
.
midprocess
(
preped_data
,
use_future
)
midped_data
=
self
.
midprocess
(
preped_data
,
use_future
)
...
@@ -906,13 +907,13 @@ class Op(object):
...
@@ -906,13 +907,13 @@ class Op(object):
data_id
=
data_id
),
data_id
=
data_id
),
output_channels
)
output_channels
)
continue
continue
_profiler
.
record
(
"{}-midp
_1"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-midp
#{}_1"
.
format
(
op_info_prefix
,
tid
))
else
:
else
:
midped_data
=
preped_data
midped_data
=
preped_data
# postprocess
# postprocess
output_data
=
None
output_data
=
None
_profiler
.
record
(
"{}-postp
_0"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-postp
#{}_0"
.
format
(
op_info_prefix
,
tid
))
if
self
.
with_serving
and
client_type
==
'grpc'
and
use_future
:
if
self
.
with_serving
and
client_type
==
'grpc'
and
use_future
:
# use call_future
# use call_future
output_data
=
ChannelData
(
output_data
=
ChannelData
(
...
@@ -949,12 +950,12 @@ class Op(object):
...
@@ -949,12 +950,12 @@ class Op(object):
ChannelDataType
.
CHANNEL_NPDATA
.
value
,
ChannelDataType
.
CHANNEL_NPDATA
.
value
,
npdata
=
postped_data
,
npdata
=
postped_data
,
data_id
=
data_id
)
data_id
=
data_id
)
_profiler
.
record
(
"{}-postp
_1"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-postp
#{}_1"
.
format
(
op_info_prefix
,
tid
))
# push data to channel (if run succ)
# push data to channel (if run succ)
_profiler
.
record
(
"{}-push
_0"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-push
#{}_0"
.
format
(
op_info_prefix
,
tid
))
self
.
_push_to_output_channels
(
output_data
,
output_channels
)
self
.
_push_to_output_channels
(
output_data
,
output_channels
)
_profiler
.
record
(
"{}-push
_1"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-push
#{}_1"
.
format
(
op_info_prefix
,
tid
))
def
_log
(
self
,
info
):
def
_log
(
self
,
info
):
return
"{} {}"
.
format
(
self
.
name
,
info
)
return
"{} {}"
.
format
(
self
.
name
,
info
)
...
@@ -994,12 +995,13 @@ class VirtualOp(Op):
...
@@ -994,12 +995,13 @@ class VirtualOp(Op):
op_info_prefix
=
"[{}|{}]"
.
format
(
self
.
name
,
concurrency_idx
)
op_info_prefix
=
"[{}|{}]"
.
format
(
self
.
name
,
concurrency_idx
)
log
=
self
.
_get_log_func
(
op_info_prefix
)
log
=
self
.
_get_log_func
(
op_info_prefix
)
self
.
_is_run
=
True
self
.
_is_run
=
True
tid
=
threading
.
current_thread
().
ident
while
self
.
_is_run
:
while
self
.
_is_run
:
_profiler
.
record
(
"{}-get
_0"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-get
#{}_0"
.
format
(
op_info_prefix
,
tid
))
channeldata
=
input_channel
.
front
(
self
.
name
)
channeldata
=
input_channel
.
front
(
self
.
name
)
_profiler
.
record
(
"{}-get
_1"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-get
#{}_1"
.
format
(
op_info_prefix
,
tid
))
_profiler
.
record
(
"{}-push
_0"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-push
#{}_0"
.
format
(
op_info_prefix
,
tid
))
if
isinstance
(
channeldata
,
dict
):
if
isinstance
(
channeldata
,
dict
):
for
name
,
data
in
channeldata
.
items
():
for
name
,
data
in
channeldata
.
items
():
self
.
_push_to_output_channels
(
self
.
_push_to_output_channels
(
...
@@ -1009,7 +1011,7 @@ class VirtualOp(Op):
...
@@ -1009,7 +1011,7 @@ class VirtualOp(Op):
channeldata
,
channeldata
,
channels
=
output_channels
,
channels
=
output_channels
,
name
=
self
.
_virtual_pred_ops
[
0
].
name
)
name
=
self
.
_virtual_pred_ops
[
0
].
name
)
_profiler
.
record
(
"{}-push
_1"
.
format
(
op_info_prefix
))
_profiler
.
record
(
"{}-push
#{}_1"
.
format
(
op_info_prefix
,
tid
))
class
GeneralPythonService
(
class
GeneralPythonService
(
...
@@ -1032,6 +1034,7 @@ class GeneralPythonService(
...
@@ -1032,6 +1034,7 @@ class GeneralPythonService(
self
.
_recive_func
=
threading
.
Thread
(
self
.
_recive_func
=
threading
.
Thread
(
target
=
GeneralPythonService
.
_recive_out_channel_func
,
args
=
(
self
,
))
target
=
GeneralPythonService
.
_recive_out_channel_func
,
args
=
(
self
,
))
self
.
_recive_func
.
start
()
self
.
_recive_func
.
start
()
self
.
_tid
=
threading
.
current_thread
().
ident
def
_log
(
self
,
info_str
):
def
_log
(
self
,
info_str
):
return
"[{}] {}"
.
format
(
self
.
name
,
info_str
)
return
"[{}] {}"
.
format
(
self
.
name
,
info_str
)
...
@@ -1133,21 +1136,21 @@ class GeneralPythonService(
...
@@ -1133,21 +1136,21 @@ class GeneralPythonService(
return
resp
return
resp
def
inference
(
self
,
request
,
context
):
def
inference
(
self
,
request
,
context
):
_profiler
.
record
(
"{}-prepack
_0"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-prepack
#{}_0"
.
format
(
self
.
name
,
self
.
_tid
))
data
,
data_id
=
self
.
_pack_data_for_infer
(
request
)
data
,
data_id
=
self
.
_pack_data_for_infer
(
request
)
_profiler
.
record
(
"{}-prepack
_1"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-prepack
#{}_1"
.
format
(
self
.
name
,
self
.
_tid
))
resp_channeldata
=
None
resp_channeldata
=
None
for
i
in
range
(
self
.
_retry
):
for
i
in
range
(
self
.
_retry
):
logging
.
debug
(
self
.
_log
(
'push data'
))
logging
.
debug
(
self
.
_log
(
'push data'
))
_profiler
.
record
(
"{}-push
_0"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-push
#{}_0"
.
format
(
self
.
name
,
self
.
_tid
))
self
.
_in_channel
.
push
(
data
,
self
.
name
)
self
.
_in_channel
.
push
(
data
,
self
.
name
)
_profiler
.
record
(
"{}-push
_1"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-push
#{}_1"
.
format
(
self
.
name
,
self
.
_tid
))
logging
.
debug
(
self
.
_log
(
'wait for infer'
))
logging
.
debug
(
self
.
_log
(
'wait for infer'
))
_profiler
.
record
(
"{}-fetch
_0"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-fetch
#{}_0"
.
format
(
self
.
name
,
self
.
_tid
))
resp_channeldata
=
self
.
_get_data_in_globel_resp_dict
(
data_id
)
resp_channeldata
=
self
.
_get_data_in_globel_resp_dict
(
data_id
)
_profiler
.
record
(
"{}-fetch
_1"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-fetch
#{}_1"
.
format
(
self
.
name
,
self
.
_tid
))
if
resp_channeldata
.
ecode
==
ChannelDataEcode
.
OK
.
value
:
if
resp_channeldata
.
ecode
==
ChannelDataEcode
.
OK
.
value
:
break
break
...
@@ -1155,9 +1158,9 @@ class GeneralPythonService(
...
@@ -1155,9 +1158,9 @@ class GeneralPythonService(
logging
.
warn
(
"retry({}): {}"
.
format
(
logging
.
warn
(
"retry({}): {}"
.
format
(
i
+
1
,
resp_channeldata
.
error_info
))
i
+
1
,
resp_channeldata
.
error_info
))
_profiler
.
record
(
"{}-postpack
_0"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-postpack
#{}_0"
.
format
(
self
.
name
,
self
.
_tid
))
resp
=
self
.
_pack_data_for_resp
(
resp_channeldata
)
resp
=
self
.
_pack_data_for_resp
(
resp_channeldata
)
_profiler
.
record
(
"{}-postpack
_1"
.
format
(
self
.
name
))
_profiler
.
record
(
"{}-postpack
#{}_1"
.
format
(
self
.
name
,
self
.
_tid
))
_profiler
.
print_profile
()
_profiler
.
print_profile
()
return
resp
return
resp
...
...
python/pipeline/operator.py
浏览文件 @
be0806cf
...
@@ -203,10 +203,11 @@ class Op(object):
...
@@ -203,10 +203,11 @@ class Op(object):
op_info_prefix
=
"[{}|{}]"
.
format
(
self
.
name
,
concurrency_idx
)
op_info_prefix
=
"[{}|{}]"
.
format
(
self
.
name
,
concurrency_idx
)
log
=
self
.
_get_log_func
(
op_info_prefix
)
log
=
self
.
_get_log_func
(
op_info_prefix
)
self
.
_is_run
=
True
self
.
_is_run
=
True
tid
=
threading
.
current_thread
().
ident
while
self
.
_is_run
:
while
self
.
_is_run
:
self
.
_profiler_record
(
"{}-get
_0"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-get
#{}_0"
.
format
(
op_info_prefix
,
tid
))
channeldata
=
input_channel
.
front
(
self
.
name
)
channeldata
=
input_channel
.
front
(
self
.
name
)
self
.
_profiler_record
(
"{}-get
_1"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-get
#{}_1"
.
format
(
op_info_prefix
,
tid
))
logging
.
debug
(
log
(
"input_data: {}"
.
format
(
channeldata
)))
logging
.
debug
(
log
(
"input_data: {}"
.
format
(
channeldata
)))
data_id
,
error_channeldata
=
self
.
_parse_channeldata
(
channeldata
)
data_id
,
error_channeldata
=
self
.
_parse_channeldata
(
channeldata
)
...
@@ -219,9 +220,11 @@ class Op(object):
...
@@ -219,9 +220,11 @@ class Op(object):
# preprecess
# preprecess
try
:
try
:
self
.
_profiler_record
(
"{}-prep_0"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-prep#{}_0"
.
format
(
op_info_prefix
,
tid
))
preped_data
=
self
.
preprocess
(
channeldata
)
preped_data
=
self
.
preprocess
(
channeldata
)
self
.
_profiler_record
(
"{}-prep_1"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-prep#{}_1"
.
format
(
op_info_prefix
,
tid
))
except
NotImplementedError
as
e
:
except
NotImplementedError
as
e
:
# preprocess function not implemented
# preprocess function not implemented
error_info
=
log
(
e
)
error_info
=
log
(
e
)
...
@@ -259,7 +262,8 @@ class Op(object):
...
@@ -259,7 +262,8 @@ class Op(object):
midped_data
=
None
midped_data
=
None
if
self
.
with_serving
:
if
self
.
with_serving
:
ecode
=
ChannelDataEcode
.
OK
.
value
ecode
=
ChannelDataEcode
.
OK
.
value
self
.
_profiler_record
(
"{}-midp_0"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-midp#{}_0"
.
format
(
op_info_prefix
,
tid
))
if
self
.
_timeout
<=
0
:
if
self
.
_timeout
<=
0
:
try
:
try
:
midped_data
=
self
.
midprocess
(
preped_data
,
use_future
)
midped_data
=
self
.
midprocess
(
preped_data
,
use_future
)
...
@@ -296,13 +300,14 @@ class Op(object):
...
@@ -296,13 +300,14 @@ class Op(object):
data_id
=
data_id
),
data_id
=
data_id
),
output_channels
)
output_channels
)
continue
continue
self
.
_profiler_record
(
"{}-midp_1"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-midp#{}_1"
.
format
(
op_info_prefix
,
tid
))
else
:
else
:
midped_data
=
preped_data
midped_data
=
preped_data
# postprocess
# postprocess
output_data
=
None
output_data
=
None
self
.
_profiler_record
(
"{}-postp
_0"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-postp
#{}_0"
.
format
(
op_info_prefix
,
tid
))
if
self
.
with_serving
and
client_type
==
'grpc'
and
use_future
:
if
self
.
with_serving
and
client_type
==
'grpc'
and
use_future
:
# use call_future
# use call_future
output_data
=
ChannelData
(
output_data
=
ChannelData
(
...
@@ -339,12 +344,12 @@ class Op(object):
...
@@ -339,12 +344,12 @@ class Op(object):
ChannelDataType
.
CHANNEL_NPDATA
.
value
,
ChannelDataType
.
CHANNEL_NPDATA
.
value
,
npdata
=
postped_data
,
npdata
=
postped_data
,
data_id
=
data_id
)
data_id
=
data_id
)
self
.
_profiler_record
(
"{}-postp
_1"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-postp
#{}_1"
.
format
(
op_info_prefix
,
tid
))
# push data to channel (if run succ)
# push data to channel (if run succ)
self
.
_profiler_record
(
"{}-push
_0"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-push
#{}_0"
.
format
(
op_info_prefix
,
tid
))
self
.
_push_to_output_channels
(
output_data
,
output_channels
)
self
.
_push_to_output_channels
(
output_data
,
output_channels
)
self
.
_profiler_record
(
"{}-push
_1"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-push
#{}_1"
.
format
(
op_info_prefix
,
tid
))
def
_log
(
self
,
info
):
def
_log
(
self
,
info
):
return
"{} {}"
.
format
(
self
.
name
,
info
)
return
"{} {}"
.
format
(
self
.
name
,
info
)
...
@@ -385,11 +390,11 @@ class VirtualOp(Op):
...
@@ -385,11 +390,11 @@ class VirtualOp(Op):
log
=
self
.
_get_log_func
(
op_info_prefix
)
log
=
self
.
_get_log_func
(
op_info_prefix
)
self
.
_is_run
=
True
self
.
_is_run
=
True
while
self
.
_is_run
:
while
self
.
_is_run
:
self
.
_profiler_record
(
"{}-get
_0"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-get
#{}_0"
.
format
(
op_info_prefix
,
tid
))
channeldata
=
input_channel
.
front
(
self
.
name
)
channeldata
=
input_channel
.
front
(
self
.
name
)
self
.
_profiler_record
(
"{}-get
_1"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-get
#{}_1"
.
format
(
op_info_prefix
,
tid
))
self
.
_profiler_record
(
"{}-push
_0"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-push
#{}_0"
.
format
(
op_info_prefix
,
tid
))
if
isinstance
(
channeldata
,
dict
):
if
isinstance
(
channeldata
,
dict
):
for
name
,
data
in
channeldata
.
items
():
for
name
,
data
in
channeldata
.
items
():
self
.
_push_to_output_channels
(
self
.
_push_to_output_channels
(
...
@@ -399,4 +404,4 @@ class VirtualOp(Op):
...
@@ -399,4 +404,4 @@ class VirtualOp(Op):
channeldata
,
channeldata
,
channels
=
output_channels
,
channels
=
output_channels
,
name
=
self
.
_virtual_pred_ops
[
0
].
name
)
name
=
self
.
_virtual_pred_ops
[
0
].
name
)
self
.
_profiler_record
(
"{}-push
_1"
.
format
(
op_info_prefix
))
self
.
_profiler_record
(
"{}-push
#{}_1"
.
format
(
op_info_prefix
,
tid
))
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录