Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
ed639511
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看板
提交
ed639511
编写于
8月 06, 2020
作者:
B
barriery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update code structure of logger module
上级
c5776b78
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
73 addition
and
79 deletion
+73
-79
python/pipeline/channel.py
python/pipeline/channel.py
+1
-1
python/pipeline/dag.py
python/pipeline/dag.py
+1
-1
python/pipeline/logger.py
python/pipeline/logger.py
+53
-60
python/pipeline/operator.py
python/pipeline/operator.py
+1
-1
python/pipeline/pipeline_client.py
python/pipeline/pipeline_client.py
+1
-1
python/pipeline/pipeline_server.py
python/pipeline/pipeline_server.py
+1
-1
python/pipeline/profiler.py
python/pipeline/profiler.py
+15
-14
未找到文件。
python/pipeline/channel.py
浏览文件 @
ed639511
...
...
@@ -29,7 +29,7 @@ import enum
import
os
import
copy
_LOGGER
=
logging
.
getLogger
(
"pipeline.channel"
)
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
ChannelDataEcode
(
enum
.
Enum
):
...
...
python/pipeline/dag.py
浏览文件 @
ed639511
...
...
@@ -32,7 +32,7 @@ from .profiler import TimeProfiler, PerformanceTracer
from
.util
import
NameGenerator
from
.proto
import
pipeline_service_pb2
_LOGGER
=
logging
.
getLogger
(
"pipeline.dag"
)
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
DAGExecutor
(
object
):
...
...
python/pipeline/logger.py
浏览文件 @
ed639511
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
import
logging
import
logging.
handlers
import
logging.
config
import
os
...
...
@@ -25,66 +25,59 @@ class SectionLevelFilter(object):
return
logRecord
.
levelno
in
self
.
_levels
class
OutOfMouduleFilter
(
object
):
def
__init__
(
self
,
out_names
):
self
.
_out_names
=
out_names
def
filter
(
self
,
logRecord
):
return
logRecord
.
name
not
in
self
.
_out_names
class
OutOfMouduleAndSectionLevelFilter
(
object
):
def
__init__
(
self
,
out_names
,
levels
):
self
.
_out_names
=
out_names
self
.
_levels
=
levels
def
filter
(
self
,
logRecord
):
if
logRecord
.
name
in
self
.
_out_names
:
return
False
return
logRecord
.
levelno
in
self
.
_levels
class
StreamHandler
(
logging
.
StreamHandler
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
StreamHandler
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
addFilter
(
OutOfMouduleFilter
([
"pipeline.profiler"
]))
log_dir
=
"PipelineServingLogs"
if
not
os
.
path
.
exists
(
log_dir
):
os
.
makedirs
(
log_dir
)
# root logger
_LOGGER
=
logging
.
getLogger
()
_LOGGER
.
setLevel
(
logging
.
DEBUG
)
formatter
=
logging
.
Formatter
(
"%(levelname)s %(asctime)s [%(filename)s:%(lineno)d] %(message)s"
)
# info and warn
file_info
=
logging
.
handlers
.
RotatingFileHandler
(
os
.
path
.
join
(
log_dir
,
"INFO.log"
))
file_info
.
addFilter
(
OutOfMouduleFilter
([
"pipeline.profiler"
]))
file_info
.
addFilter
(
SectionLevelFilter
([
logging
.
INFO
,
logging
.
WARNING
]))
file_info
.
setFormatter
(
formatter
)
# err and critical
file_err
=
logging
.
handlers
.
RotatingFileHandler
(
os
.
path
.
join
(
log_dir
,
"ERROR.log"
))
file_err
.
addFilter
(
OutOfMouduleFilter
([
"pipeline.profiler"
]))
file_err
.
setLevel
(
logging
.
ERROR
)
file_err
.
setFormatter
(
formatter
)
_LOGGER
.
addHandler
(
file_info
)
_LOGGER
.
addHandler
(
file_err
)
# tracer logger
_TRACER
=
logging
.
getLogger
(
"pipeline.profiler"
)
_TRACER
.
setLevel
(
logging
.
INFO
)
_TRACER
.
addFilter
(
logging
.
Filter
(
"pipeline.profiler"
))
# tracer
tracer_formatter
=
logging
.
Formatter
(
"%(asctime)s %(message)s"
)
file_trace
=
logging
.
handlers
.
RotatingFileHandler
(
os
.
path
.
join
(
log_dir
,
"TRACE.log"
))
file_trace
.
setFormatter
(
tracer_formatter
)
_TRACER
.
addHandler
(
file_trace
)
logger_config
=
{
"version"
:
1
,
"formatters"
:
{
"normal_fmt"
:
{
"format"
:
"%(levelname)s %(asctime)s [%(filename)s:%(lineno)d] %(message)s"
,
},
"tracer_fmt"
:
{
"format"
:
"%(asctime)s %(message)s"
,
},
},
"filters"
:
{
"info_only_filter"
:
{
"()"
:
SectionLevelFilter
,
"levels"
:
[
logging
.
INFO
],
},
},
"handlers"
:
{
"f_pipeline.log"
:
{
"class"
:
"logging.FileHandler"
,
"level"
:
"INFO"
,
"formatter"
:
"normal_fmt"
,
"filters"
:
[
"info_only_filter"
],
"filename"
:
os
.
path
.
join
(
log_dir
,
"pipeline.log"
),
},
"f_pipeline.log.wf"
:
{
"class"
:
"logging.FileHandler"
,
"level"
:
"WARNING"
,
"formatter"
:
"normal_fmt"
,
"filename"
:
os
.
path
.
join
(
log_dir
,
"pipeline.log.wf"
),
},
"f_tracer.log"
:
{
"class"
:
"logging.FileHandler"
,
"level"
:
"INFO"
,
"formatter"
:
"tracer_fmt"
,
"filename"
:
os
.
path
.
join
(
log_dir
,
"pipeline.tracer"
),
},
},
"loggers"
:
{
# propagate = True
"."
.
join
(
__name__
.
split
(
"."
)[:
-
1
]
+
[
"profiler"
]):
{
"level"
:
"INFO"
,
"handlers"
:
[
"f_tracer.log"
],
},
},
"root"
:
{
"level"
:
"DEBUG"
,
"handlers"
:
[
"f_pipeline.log"
,
"f_pipeline.log.wf"
],
},
}
logging
.
config
.
dictConfig
(
logger_config
)
python/pipeline/operator.py
浏览文件 @
ed639511
...
...
@@ -32,7 +32,7 @@ from .channel import (ThreadChannel, ProcessChannel, ChannelDataEcode,
from
.util
import
NameGenerator
from
.profiler
import
UnsafeTimeProfiler
as
TimeProfiler
_LOGGER
=
logging
.
getLogger
(
"pipeline.operator"
)
_LOGGER
=
logging
.
getLogger
(
__name__
)
_op_name_gen
=
NameGenerator
(
"Op"
)
...
...
python/pipeline/pipeline_client.py
浏览文件 @
ed639511
...
...
@@ -22,7 +22,7 @@ from .channel import ChannelDataEcode
from
.proto
import
pipeline_service_pb2
from
.proto
import
pipeline_service_pb2_grpc
_LOGGER
=
logging
.
getLogger
(
"pipeline.pipeline_client"
)
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
PipelineClient
(
object
):
...
...
python/pipeline/pipeline_server.py
浏览文件 @
ed639511
...
...
@@ -26,7 +26,7 @@ from .proto import pipeline_service_pb2_grpc
from
.operator
import
ResponseOp
from
.dag
import
DAGExecutor
_LOGGER
=
logging
.
getLogger
(
"pipeline.pipeline_server"
)
_LOGGER
=
logging
.
getLogger
(
__name__
)
class
PipelineServicer
(
pipeline_service_pb2_grpc
.
PipelineServiceServicer
):
...
...
python/pipeline/profiler.py
浏览文件 @
ed639511
...
...
@@ -27,7 +27,8 @@ import time
import
threading
import
multiprocessing
_TRACER
=
logging
.
getLogger
(
"pipeline.profiler"
)
_LOGGER
=
logging
.
getLogger
(
__name__
)
_LOGGER
.
propagate
=
False
class
PerformanceTracer
(
object
):
...
...
@@ -73,7 +74,7 @@ class PerformanceTracer(object):
op_cost
=
{}
err_count
=
0
_
TRAC
ER
.
info
(
"==================== TRACER ======================"
)
_
LOGG
ER
.
info
(
"==================== TRACER ======================"
)
# op
while
True
:
try
:
...
...
@@ -98,15 +99,15 @@ class PerformanceTracer(object):
tot_cost
+=
op_cost
[
name
][
action
]
if
name
!=
"DAG"
:
_
TRAC
ER
.
info
(
"Op({}):"
.
format
(
name
))
_
LOGG
ER
.
info
(
"Op({}):"
.
format
(
name
))
for
action
in
actions
:
if
action
in
op_cost
[
name
]:
_
TRAC
ER
.
info
(
"
\t
{}[{} ms]"
.
format
(
_
LOGG
ER
.
info
(
"
\t
{}[{} ms]"
.
format
(
action
,
op_cost
[
name
][
action
]))
for
action
in
calcu_actions
:
if
action
in
op_cost
[
name
]:
calcu_cost
+=
op_cost
[
name
][
action
]
_
TRAC
ER
.
info
(
"
\t
idle[{}]"
.
format
(
1
-
1.0
*
calcu_cost
/
_
LOGG
ER
.
info
(
"
\t
idle[{}]"
.
format
(
1
-
1.0
*
calcu_cost
/
tot_cost
))
if
"DAG"
in
op_cost
:
...
...
@@ -116,21 +117,21 @@ class PerformanceTracer(object):
qps
=
1.0
*
tot
/
self
.
_interval_s
ave_cost
=
sum
(
calls
)
/
tot
latencys
=
[
50
,
60
,
70
,
80
,
90
,
95
,
99
]
_
TRAC
ER
.
info
(
"DAGExecutor:"
)
_
TRAC
ER
.
info
(
"
\t
query count[{}]"
.
format
(
tot
))
_
TRAC
ER
.
info
(
"
\t
qps[{} q/s]"
.
format
(
qps
))
_
TRAC
ER
.
info
(
"
\t
succ[{}]"
.
format
(
1
-
1.0
*
err_count
/
tot
))
_
TRAC
ER
.
info
(
"
\t
latency:"
)
_
TRAC
ER
.
info
(
"
\t\t
ave[{} ms]"
.
format
(
ave_cost
))
_
LOGG
ER
.
info
(
"DAGExecutor:"
)
_
LOGG
ER
.
info
(
"
\t
query count[{}]"
.
format
(
tot
))
_
LOGG
ER
.
info
(
"
\t
qps[{} q/s]"
.
format
(
qps
))
_
LOGG
ER
.
info
(
"
\t
succ[{}]"
.
format
(
1
-
1.0
*
err_count
/
tot
))
_
LOGG
ER
.
info
(
"
\t
latency:"
)
_
LOGG
ER
.
info
(
"
\t\t
ave[{} ms]"
.
format
(
ave_cost
))
for
latency
in
latencys
:
_
TRAC
ER
.
info
(
"
\t\t
.{}[{} ms]"
.
format
(
latency
,
calls
[
int
(
_
LOGG
ER
.
info
(
"
\t\t
.{}[{} ms]"
.
format
(
latency
,
calls
[
int
(
tot
*
latency
/
100.0
)]))
# channel
_
TRAC
ER
.
info
(
"Channel (server worker num[{}]):"
.
format
(
_
LOGG
ER
.
info
(
"Channel (server worker num[{}]):"
.
format
(
self
.
_server_worker_num
))
for
channel
in
channels
:
_
TRAC
ER
.
info
(
"
\t
{}(In: {}, Out: {}) size[{}/{}]"
.
format
(
_
LOGG
ER
.
info
(
"
\t
{}(In: {}, Out: {}) size[{}/{}]"
.
format
(
channel
.
name
,
channel
.
get_producers
(),
channel
.
get_consumers
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录