Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
f17f924e
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看板
提交
f17f924e
编写于
7月 06, 2020
作者:
B
barrierye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix bug in dag executor
上级
c045eebb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
43 addition
and
25 deletion
+43
-25
python/pipeline/dag.py
python/pipeline/dag.py
+26
-17
python/pipeline/operator.py
python/pipeline/operator.py
+13
-7
python/pipeline/profiler.py
python/pipeline/profiler.py
+4
-1
未找到文件。
python/pipeline/dag.py
浏览文件 @
f17f924e
...
...
@@ -15,6 +15,7 @@
import
threading
import
multiprocessing
import
sys
import
copy
if
sys
.
version_info
.
major
==
2
:
import
Queue
elif
sys
.
version_info
.
major
==
3
:
...
...
@@ -58,8 +59,8 @@ class DAGExecutor(object):
self
.
_profiler
=
TimeProfiler
()
self
.
_profiler
.
enable
(
use_profile
)
self
.
_dag
=
DAG
(
response_op
,
self
.
_profiler
,
use_profil
e
,
use_multithread
,
client_type
,
channel_size
)
self
.
_dag
=
DAG
(
response_op
,
use_profile
,
use_multithread
,
client_typ
e
,
channel_size
)
(
in_channel
,
out_channel
,
pack_rpc_func
,
unpack_rpc_func
)
=
self
.
_dag
.
build
()
self
.
_dag
.
start
()
...
...
@@ -75,8 +76,9 @@ class DAGExecutor(object):
self
.
_id_lock
=
threading
.
Lock
()
self
.
_id_counter
=
0
self
.
_reset_max_id
=
1000000000000000000
self
.
_cv
=
threading
.
Condition
()
self
.
_fetch_buffer
=
{}
self
.
_cv_pool
=
{}
self
.
_cv_for_cv_pool
=
threading
.
Condition
()
self
.
_fetch_buffer
=
None
self
.
_is_run
=
False
self
.
_recive_func
=
None
...
...
@@ -115,6 +117,7 @@ class DAGExecutor(object):
self
.
_out_channel
=
out_channel
def
_recive_out_channel_func
(
self
):
cv
=
None
while
self
.
_is_run
:
channeldata_dict
=
self
.
_out_channel
.
front
(
self
.
name
)
if
len
(
channeldata_dict
)
!=
1
:
...
...
@@ -125,18 +128,25 @@ class DAGExecutor(object):
raise
TypeError
(
self
.
_log
(
'data must be ChannelData type, but get {}'
.
format
(
type
(
channeldata
))))
with
self
.
_cv
:
data_id
=
channeldata
.
id
self
.
_fetch_buffer
[
data_id
]
=
channeldata
self
.
_cv
.
notify_all
()
data_id
=
channeldata
.
id
_LOGGER
.
debug
(
"recive thread fetch data: {}"
.
format
(
data_id
))
with
self
.
_cv_for_cv_pool
:
cv
=
self
.
_cv_pool
[
data_id
]
with
cv
:
self
.
_fetch_buffer
=
channeldata
cv
.
notify_all
()
def
_get_channeldata_from_fetch_buffer
(
self
,
data_id
):
resp
=
None
with
self
.
_cv
:
while
data_id
not
in
self
.
_fetch_buffer
:
self
.
_cv
.
wait
()
resp
=
self
.
_fetch_buffer
.
pop
(
data_id
)
self
.
_cv
.
notify_all
()
cv
=
threading
.
Condition
()
with
self
.
_cv_for_cv_pool
:
self
.
_cv_pool
[
data_id
]
=
cv
with
cv
:
cv
.
wait
()
_LOGGER
.
debug
(
"resp func get lock (data_id: {})"
.
format
(
data_id
))
resp
=
copy
.
deepcopy
(
self
.
_fetch_buffer
)
# cv.notify_all()
return
resp
def
_pack_channeldata
(
self
,
rpc_request
,
data_id
):
...
...
@@ -204,8 +214,8 @@ class DAGExecutor(object):
class
DAG
(
object
):
def
__init__
(
self
,
response_op
,
profiler
,
use_profile
,
use_multithread
,
c
lient_type
,
c
hannel_size
):
def
__init__
(
self
,
response_op
,
use_profile
,
use_multithread
,
client_type
,
channel_size
):
self
.
_response_op
=
response_op
self
.
_use_profile
=
use_profile
self
.
_use_multithread
=
use_multithread
...
...
@@ -213,7 +223,6 @@ class DAG(object):
self
.
_client_type
=
client_type
if
not
self
.
_use_multithread
:
self
.
_manager
=
multiprocessing
.
Manager
()
self
.
_profiler
=
profiler
def
get_use_ops
(
self
,
response_op
):
unique_names
=
set
()
...
...
@@ -413,7 +422,7 @@ class DAG(object):
def
start
(
self
):
self
.
_threads_or_proces
=
[]
for
op
in
self
.
_actual_ops
:
op
.
init_profiler
(
self
.
_profiler
,
self
.
_use_profile
)
op
.
use_profiler
(
self
.
_use_profile
)
if
self
.
_use_multithread
:
self
.
_threads_or_proces
.
extend
(
op
.
start_with_thread
(
self
.
_client_type
))
...
...
python/pipeline/operator.py
浏览文件 @
f17f924e
...
...
@@ -20,6 +20,7 @@ from concurrent import futures
import
logging
import
func_timeout
import
os
import
sys
from
numpy
import
*
from
.proto
import
pipeline_service_pb2
...
...
@@ -59,14 +60,14 @@ class Op(object):
self
.
_retry
=
max
(
1
,
retry
)
self
.
_input
=
None
self
.
_outputs
=
[]
self
.
_profiler
=
None
self
.
_use_profile
=
False
# only for multithread
self
.
_for_init_op_lock
=
threading
.
Lock
()
self
.
_succ_init_op
=
False
def
init_profiler
(
self
,
profiler
,
use_profile
):
self
.
_profiler
=
profiler
def
use_profiler
(
self
,
use_profile
):
self
.
_use_profile
=
use_profile
def
_profiler_record
(
self
,
string
):
...
...
@@ -351,9 +352,8 @@ class Op(object):
os
.
_exit
(
-
1
)
# init profiler
if
not
use_multithread
:
self
.
_profiler
=
TimeProfiler
()
self
.
_profiler
.
enable
(
self
.
_use_profile
)
self
.
_profiler
=
TimeProfiler
()
self
.
_profiler
.
enable
(
self
.
_use_profile
)
self
.
_is_run
=
True
while
self
.
_is_run
:
...
...
@@ -400,11 +400,17 @@ class Op(object):
output_channels
)
continue
if
self
.
_use_profile
:
profile_str
=
self
.
_profiler
.
gen_profile_str
()
sys
.
stderr
.
write
(
profile_str
)
#TODO
#output_data.add_profile(profile_str)
# push data to channel (if run succ)
#self._profiler_record("push#{}_0".format(op_info_prefix))
self
.
_push_to_output_channels
(
output_data
,
output_channels
)
#self._profiler_record("push#{}_1".format(op_info_prefix))
self
.
_profiler
.
print_profile
()
#
self._profiler.print_profile()
def
_log
(
self
,
info
):
return
"{} {}"
.
format
(
self
.
name
,
info
)
...
...
python/pipeline/profiler.py
浏览文件 @
f17f924e
...
...
@@ -50,6 +50,9 @@ class TimeProfiler(object):
self
.
_time_record
.
put
((
name
,
tag
,
timestamp
))
def
print_profile
(
self
):
sys
.
stderr
.
write
(
self
.
gen_profile_str
())
def
gen_profile_str
(
self
):
if
self
.
_enable
is
False
:
return
print_str
=
self
.
_print_head
...
...
@@ -64,7 +67,7 @@ class TimeProfiler(object):
else
:
tmp
[
name
]
=
(
tag
,
timestamp
)
print_str
=
"
\n
{}
\n
"
.
format
(
print_str
)
sys
.
stderr
.
write
(
print_str
)
for
name
,
item
in
tmp
.
items
():
tag
,
timestamp
=
item
self
.
_time_record
.
put
((
name
,
tag
,
timestamp
))
return
print_str
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录