Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
5549d161
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看板
提交
5549d161
编写于
8月 10, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update tracer
上级
4fee0cee
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
62 addition
and
29 deletion
+62
-29
python/pipeline/dag.py
python/pipeline/dag.py
+9
-6
python/pipeline/operator.py
python/pipeline/operator.py
+29
-9
python/pipeline/profiler.py
python/pipeline/profiler.py
+24
-14
未找到文件。
python/pipeline/dag.py
浏览文件 @
5549d161
...
...
@@ -24,6 +24,7 @@ else:
raise
Exception
(
"Error Python version"
)
import
os
import
logging
import
collections
from
.operator
import
Op
,
RequestOp
,
ResponseOp
,
VirtualOp
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelData
,
...
...
@@ -284,12 +285,14 @@ class DAGExecutor(object):
end_call
=
self
.
_profiler
.
record
(
"call_{}#DAG_1"
.
format
(
data_id
))
if
self
.
_tracer
is
not
None
:
if
resp_channeldata
.
ecode
==
ChannelDataEcode
.
OK
.
value
:
trace_buffer
.
put
((
"DAG"
,
"call_{}"
.
format
(
data_id
),
True
,
end_call
-
start_call
))
else
:
trace_buffer
.
put
((
"DAG"
,
"call_{}"
.
format
(
data_id
),
False
,
end_call
-
start_call
))
trace_buffer
.
put_nowait
({
"name"
:
"DAG"
,
"id"
:
data_id
,
"succ"
:
resp_channeldata
.
ecode
==
ChannelDataEcode
.
OK
.
value
,
"actions"
:
{
"call_{}"
.
format
(
data_id
):
end_call
-
start_call
,
},
})
profile_str
=
self
.
_profiler
.
gen_profile_str
()
if
self
.
_server_use_profile
:
...
...
python/pipeline/operator.py
浏览文件 @
5549d161
...
...
@@ -25,6 +25,12 @@ import sys
import
collections
import
numpy
as
np
from
numpy
import
*
if
sys
.
version_info
.
major
==
2
:
import
Queue
elif
sys
.
version_info
.
major
==
3
:
import
queue
as
Queue
else
:
raise
Exception
(
"Error Python version"
)
from
.proto
import
pipeline_service_pb2
from
.channel
import
(
ThreadChannel
,
ProcessChannel
,
ChannelDataEcode
,
...
...
@@ -532,6 +538,7 @@ class Op(object):
op_info_prefix
=
op_info_prefix
)
start
,
end
=
None
,
None
trace_que
=
collections
.
deque
()
while
True
:
start
=
int
(
round
(
_time
()
*
1000000
))
try
:
...
...
@@ -541,8 +548,7 @@ class Op(object):
self
.
_finalize
(
is_thread_op
)
break
end
=
int
(
round
(
_time
()
*
1000000
))
if
trace_buffer
is
not
None
:
trace_buffer
.
put
((
self
.
name
,
"in"
,
True
,
end
-
start
))
in_time
=
end
-
start
# parse channeldata batch
try
:
...
...
@@ -562,8 +568,7 @@ class Op(object):
preped_data_dict
,
err_channeldata_dict
\
=
self
.
_run_preprocess
(
parsed_data_dict
,
op_info_prefix
)
end
=
profiler
.
record
(
"prep#{}_1"
.
format
(
op_info_prefix
))
if
trace_buffer
is
not
None
:
trace_buffer
.
put
((
self
.
name
,
"prep"
,
True
,
end
-
start
))
prep_time
=
end
-
start
try
:
for
data_id
,
err_channeldata
in
err_channeldata_dict
.
items
():
self
.
_push_to_output_channels
(
...
...
@@ -583,8 +588,7 @@ class Op(object):
midped_data_dict
,
err_channeldata_dict
\
=
self
.
_run_process
(
preped_data_dict
,
op_info_prefix
)
end
=
profiler
.
record
(
"midp#{}_1"
.
format
(
op_info_prefix
))
if
trace_buffer
is
not
None
:
trace_buffer
.
put
((
self
.
name
,
"midp"
,
True
,
end
-
start
))
midp_time
=
end
-
start
try
:
for
data_id
,
err_channeldata
in
err_channeldata_dict
.
items
():
self
.
_push_to_output_channels
(
...
...
@@ -605,8 +609,7 @@ class Op(object):
=
self
.
_run_postprocess
(
parsed_data_dict
,
midped_data_dict
,
op_info_prefix
)
end
=
profiler
.
record
(
"postp#{}_1"
.
format
(
op_info_prefix
))
if
trace_buffer
is
not
None
:
trace_buffer
.
put
((
self
.
name
,
"postp"
,
True
,
end
-
start
))
postp_time
=
end
-
start
try
:
for
data_id
,
err_channeldata
in
err_channeldata_dict
.
items
():
self
.
_push_to_output_channels
(
...
...
@@ -639,8 +642,25 @@ class Op(object):
self
.
_finalize
(
is_thread_op
)
break
end
=
int
(
round
(
_time
()
*
1000000
))
out_time
=
end
-
start
if
trace_buffer
is
not
None
:
trace_buffer
.
put
((
self
.
name
,
"out"
,
True
,
end
-
start
))
trace_que
.
append
({
"name"
:
self
.
name
,
"actions"
:
{
"in"
:
in_time
,
"prep"
:
prep_time
,
"midp"
:
midp_time
,
"postp"
:
postp_time
,
"out"
:
out_time
,
}
})
while
trace_que
:
info
=
trace_que
[
0
]
try
:
trace_buffer
.
put_nowait
(
info
)
trace_que
.
popleft
()
except
Queue
.
Full
:
break
def
_initialize
(
self
,
is_thread_op
,
client_type
,
concurrency_idx
):
if
is_thread_op
:
...
...
python/pipeline/profiler.py
浏览文件 @
5549d161
...
...
@@ -68,26 +68,35 @@ class PerformanceTracer(object):
self
.
_channels
=
channels
def
_trace_func
(
self
,
channels
):
actions
=
[
"in"
,
"prep"
,
"midp"
,
"postp"
,
"out"
]
a
ll_a
ctions
=
[
"in"
,
"prep"
,
"midp"
,
"postp"
,
"out"
]
calcu_actions
=
[
"prep"
,
"midp"
,
"postp"
]
while
True
:
op_cost
=
{}
err_request
=
[]
err_count
=
0
_LOGGER
.
info
(
"==================== TRACER ======================"
)
# op
while
True
:
try
:
name
,
action
,
stage
,
cost
=
self
.
_data_buffer
.
get_nowait
()
if
stage
==
False
:
# only for name == DAG
assert
name
==
"DAG"
err_count
+=
1
item
=
self
.
_data_buffer
.
get_nowait
()
name
=
item
[
"name"
]
actions
=
item
[
"actions"
]
if
name
==
"DAG"
:
succ
=
item
[
"succ"
]
req_id
=
item
[
"id"
]
if
not
succ
:
err_count
+=
1
err_request
.
append
(
req_id
)
if
name
not
in
op_cost
:
op_cost
[
name
]
=
{}
if
action
not
in
op_cost
[
name
]:
op_cost
[
name
][
action
]
=
[]
op_cost
[
name
][
action
].
append
(
cost
)
for
action
,
cost
in
actions
.
items
():
if
action
not
in
op_cost
[
name
]:
op_cost
[
name
][
action
]
=
[]
op_cost
[
name
][
action
].
append
(
cost
)
except
Queue
.
Empty
:
break
...
...
@@ -100,7 +109,7 @@ class PerformanceTracer(object):
if
name
!=
"DAG"
:
_LOGGER
.
info
(
"Op({}):"
.
format
(
name
))
for
action
in
actions
:
for
action
in
a
ll_a
ctions
:
if
action
in
op_cost
[
name
]:
_LOGGER
.
info
(
"
\t
{}[{} ms]"
.
format
(
action
,
op_cost
[
name
][
action
]))
...
...
@@ -118,10 +127,11 @@ class PerformanceTracer(object):
ave_cost
=
sum
(
calls
)
/
tot
latencys
=
[
50
,
60
,
70
,
80
,
90
,
95
,
99
]
_LOGGER
.
info
(
"DAGExecutor:"
)
_LOGGER
.
info
(
"
\t
query count[{}]"
.
format
(
tot
))
_LOGGER
.
info
(
"
\t
qps[{} q/s]"
.
format
(
qps
))
_LOGGER
.
info
(
"
\t
succ[{}]"
.
format
(
1
-
1.0
*
err_count
/
tot
))
_LOGGER
.
info
(
"
\t
latency:"
)
_LOGGER
.
info
(
"
\t
Query count[{}]"
.
format
(
tot
))
_LOGGER
.
info
(
"
\t
QPS[{} q/s]"
.
format
(
qps
))
_LOGGER
.
info
(
"
\t
Succ[{}]"
.
format
(
1
-
1.0
*
err_count
/
tot
))
_LOGGER
.
info
(
"
\t
Error req[{}]"
.
format
([
", "
.
join
([
str
(
x
)
for
x
in
err_request
])]))
_LOGGER
.
info
(
"
\t
Latency:"
)
_LOGGER
.
info
(
"
\t\t
ave[{} ms]"
.
format
(
ave_cost
))
for
latency
in
latencys
:
_LOGGER
.
info
(
"
\t\t
.{}[{} ms]"
.
format
(
latency
,
calls
[
int
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录