Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
42510327
R
Rust
项目概览
int
/
Rust
接近 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
42510327
编写于
7月 23, 2017
作者:
M
Matthew Hammer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
-Z profile-queries includes dep_graph.with_task uses in output
上级
3c24fea8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
99 addition
and
13 deletion
+99
-13
src/librustc/dep_graph/graph.rs
src/librustc/dep_graph/graph.rs
+7
-0
src/librustc/util/common.rs
src/librustc/util/common.rs
+6
-1
src/librustc_driver/profile/mod.rs
src/librustc_driver/profile/mod.rs
+53
-12
src/librustc_driver/profile/trace.rs
src/librustc_driver/profile/trace.rs
+33
-0
未找到文件。
src/librustc/dep_graph/graph.rs
浏览文件 @
42510327
...
...
@@ -12,6 +12,7 @@
use
session
::
config
::
OutputType
;
use
std
::
cell
::{
Ref
,
RefCell
};
use
std
::
rc
::
Rc
;
use
util
::
common
::{
ProfileQueriesMsg
,
profq_msg
};
use
super
::
dep_node
::{
DepNode
,
DepKind
,
WorkProductId
};
use
super
::
query
::
DepGraphQuery
;
...
...
@@ -118,7 +119,13 @@ pub fn with_task<C, A, R>(&self,
{
if
let
Some
(
ref
data
)
=
self
.data
{
data
.edges
.borrow_mut
()
.push_task
(
key
);
if
cfg!
(
debug_assertions
)
{
profq_msg
(
ProfileQueriesMsg
::
TaskBegin
(
key
.clone
()))
};
let
result
=
task
(
cx
,
arg
);
if
cfg!
(
debug_assertions
)
{
profq_msg
(
ProfileQueriesMsg
::
TaskEnd
)
};
let
dep_node_index
=
data
.edges
.borrow_mut
()
.pop_task
(
key
);
(
result
,
dep_node_index
)
}
else
{
...
...
src/librustc/util/common.rs
浏览文件 @
42510327
...
...
@@ -22,6 +22,7 @@
use
std
::
sync
::
mpsc
::{
Sender
};
use
syntax_pos
::{
Span
};
use
ty
::
maps
::{
QueryMsg
};
use
dep_graph
::{
DepNode
};
// The name of the associated type for `Fn` return types
pub
const
FN_OUTPUT_NAME
:
&
'static
str
=
"Output"
;
...
...
@@ -53,8 +54,12 @@ pub struct ProfQDumpParams {
pub
enum
ProfileQueriesMsg
{
/// begin a timed pass
TimeBegin
(
String
),
// end a timed pass
//
/
end a timed pass
TimeEnd
,
/// begin a task (see dep_graph::graph::with_task)
TaskBegin
(
DepNode
),
/// end a task
TaskEnd
,
/// begin a new query
QueryBegin
(
Span
,
QueryMsg
),
/// query is satisfied by using an already-known value for the given key
...
...
src/librustc_driver/profile/mod.rs
浏览文件 @
42510327
...
...
@@ -12,6 +12,7 @@
use
rustc
::
util
::
common
::{
ProfQDumpParams
,
ProfileQueriesMsg
,
profq_msg
,
profq_set_chan
};
use
std
::
sync
::
mpsc
::{
Receiver
};
use
std
::
io
::{
Write
};
use
rustc
::
dep_graph
::{
DepNode
};
pub
mod
trace
;
...
...
@@ -52,6 +53,8 @@ enum ParseState {
HaveQuery
(
trace
::
Query
,
Instant
),
// Have "time-begin" information from the last message (doit flag, and message)
HaveTimeBegin
(
String
,
Instant
),
// Have "task-begin" information from the last message
HaveTaskBegin
(
DepNode
,
Instant
),
}
struct
StackFrame
{
pub
parse_st
:
ParseState
,
...
...
@@ -170,7 +173,7 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
}
}
}
},
},
(
ParseState
::
Clear
,
...
...
@@ -212,19 +215,44 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
},
(
_
,
ProfileQueriesMsg
::
TimeEnd
)
=>
{
panic!
(
"parse error"
)
}
(
ParseState
::
Clear
,
ProfileQueriesMsg
::
TaskBegin
(
key
))
=>
{
let
start
=
Instant
::
now
();
frame
.parse_st
=
ParseState
::
HaveTaskBegin
(
key
,
start
);
stack
.push
(
frame
);
frame
=
StackFrame
{
parse_st
:
ParseState
::
Clear
,
traces
:
vec!
[]};
},
(
_
,
ProfileQueriesMsg
::
TaskBegin
(
_
))
=>
panic!
(
"parse error; did not expect time begin here"
),
// Parse State: HaveTimeBegin -- for timing old
// passes in driver (outside of query model, but
// still in use)
(
ParseState
::
HaveTimeBegin
(
_
,
_
),
ProfileQueriesMsg
::
ProviderBegin
)
=>
{
(
ParseState
::
Clear
,
ProfileQueriesMsg
::
TaskEnd
)
=>
{
let
provider_extent
=
frame
.traces
;
match
stack
.pop
()
{
None
=>
panic!
(
"parse error: expected a stack frame; found an empty stack"
),
Some
(
old_frame
)
=>
{
match
old_frame
.parse_st
{
ParseState
::
HaveTaskBegin
(
key
,
start
)
=>
{
let
duration
=
start
.elapsed
();
frame
=
StackFrame
{
parse_st
:
ParseState
::
Clear
,
traces
:
old_frame
.traces
};
let
trace
=
Rec
{
effect
:
Effect
::
TaskBegin
(
key
),
extent
:
Box
::
new
(
provider_extent
),
start
:
start
,
duration
:
duration
,
};
frame
.traces
.push
(
trace
);
},
_
=>
panic!
(
"internal parse error: malformed parse stack"
)
}
}
}
},
(
ParseState
::
HaveTimeBegin
(
_
,
_
),
ProfileQueriesMsg
::
CacheHit
)
=>
{
unreachable!
()
},
(
ParseState
::
HaveTimeBegin
(
_
,
_
),
ProfileQueriesMsg
::
QueryBegin
(
_
,
_
))
=>
{
unreachable!
()
},
(
ParseState
::
HaveTimeBegin
(
_
,
_
),
ProfileQueriesMsg
::
ProviderEnd
)
=>
{
unreachable!
()
},
(
_
,
ProfileQueriesMsg
::
TaskEnd
)
=>
{
panic!
(
"parse error"
)
}
// Parse State: HaveQuery
(
ParseState
::
HaveQuery
(
q
,
start
),
...
...
@@ -244,6 +272,11 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
stack
.push
(
frame
);
frame
=
StackFrame
{
parse_st
:
ParseState
::
Clear
,
traces
:
vec!
[]};
},
//
//
// Parse errors:
(
ParseState
::
HaveQuery
(
q
,
_
),
ProfileQueriesMsg
::
ProviderEnd
)
=>
{
panic!
(
"parse error: unexpected ProviderEnd;
\
...
...
@@ -255,7 +288,15 @@ fn profile_queries_thread(r:Receiver<ProfileQueriesMsg>) {
earlier query is unfinished: {:?} and now {:?}"
,
q1
,
Query
{
span
:
span2
,
msg
:
querymsg2
})
},
(
ParseState
::
HaveTimeBegin
(
_
,
_
),
_
)
=>
{
unreachable!
()
},
(
ParseState
::
HaveTaskBegin
(
_
,
_
),
_
)
=>
{
unreachable!
()
},
}
}
}
}
...
...
src/librustc_driver/profile/trace.rs
浏览文件 @
42510327
...
...
@@ -14,6 +14,7 @@
use
std
::
fs
::
File
;
use
std
::
time
::{
Duration
,
Instant
};
use
std
::
collections
::
hash_map
::
HashMap
;
use
rustc
::
dep_graph
::{
DepNode
};
#[derive(Debug,
Clone,
Eq,
PartialEq)]
pub
struct
Query
{
...
...
@@ -23,6 +24,7 @@ pub struct Query {
pub
enum
Effect
{
QueryBegin
(
Query
,
CacheCase
),
TimeBegin
(
String
),
TaskBegin
(
DepNode
),
}
pub
enum
CacheCase
{
Hit
,
Miss
...
...
@@ -46,6 +48,13 @@ pub fn cons_of_query_msg(q: &trace::Query) -> String {
cons
[
0
]
.to_string
()
}
pub
fn
cons_of_key
(
k
:
&
DepNode
)
->
String
{
let
s
=
format!
(
"{:?}"
,
k
);
let
cons
:
Vec
<&
str
>
=
s
.split
(|
d
|
d
==
'('
||
d
==
'{'
)
.collect
();
assert
!
(
cons
.len
()
>
0
&&
cons
[
0
]
!=
""
);
cons
[
0
]
.to_string
()
}
// First return value is text; second return value is a CSS class
pub
fn
html_of_effect
(
eff
:
&
Effect
)
->
(
String
,
String
)
{
match
*
eff
{
...
...
@@ -53,6 +62,10 @@ pub fn html_of_effect(eff: &Effect) -> (String, String) {
(
msg
.clone
(),
format!
(
"time-begin"
))
},
Effect
::
TaskBegin
(
ref
key
)
=>
{
let
cons
=
cons_of_key
(
key
);
(
cons
.clone
(),
format!
(
"{} task-begin"
,
cons
))
},
Effect
::
QueryBegin
(
ref
qmsg
,
ref
cc
)
=>
{
let
cons
=
cons_of_query_msg
(
qmsg
);
(
cons
.clone
(),
...
...
@@ -146,6 +159,20 @@ fn compute_counts_rec(counts: &mut HashMap<String,QueryMetric>, traces: &Vec<Rec
}};
counts
.insert
(
msg
.clone
(),
qm
);
},
Effect
::
TaskBegin
(
ref
key
)
=>
{
let
cons
=
cons_of_key
(
key
);
let
qm
=
match
counts
.get
(
&
cons
)
{
Some
(
qm
)
=>
QueryMetric
{
count
:
qm
.count
+
1
,
duration
:
qm
.duration
+
t
.duration
},
None
=>
QueryMetric
{
count
:
1
,
duration
:
t
.duration
}};
counts
.insert
(
cons
,
qm
);
},
Effect
::
QueryBegin
(
ref
qmsg
,
ref
_
cc
)
=>
{
let
qcons
=
cons_of_query_msg
(
qmsg
);
let
qm
=
match
counts
.get
(
&
qcons
)
{
...
...
@@ -209,6 +236,12 @@ pub fn write_style(html_file: &mut File) {
margin: 1px;
font-size: 0px;
}
.task-begin {
border-width: 1px;
color: white;
border-color: #ff8;
font-size: 0px;
}
.miss {
border-color: red;
border-width: 1px;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录