Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
7aa7198b
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
7aa7198b
编写于
4月 01, 2018
作者:
J
John Kåre Alsaker
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make PerfStats thread-safe and remove unused fields
上级
05c4ea47
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
79 deletion
+27
-79
src/librustc/infer/canonical.rs
src/librustc/infer/canonical.rs
+2
-2
src/librustc/session/mod.rs
src/librustc/session/mod.rs
+16
-58
src/librustc/util/common.rs
src/librustc/util/common.rs
+5
-12
src/librustc_traits/normalize_erasing_regions.rs
src/librustc_traits/normalize_erasing_regions.rs
+2
-5
src/librustc_traits/normalize_projection_ty.rs
src/librustc_traits/normalize_projection_ty.rs
+2
-2
未找到文件。
src/librustc/infer/canonical.rs
浏览文件 @
7aa7198b
...
...
@@ -36,13 +36,13 @@
use
serialize
::
UseSpecializedDecodable
;
use
std
::
fmt
::
Debug
;
use
std
::
ops
::
Index
;
use
std
::
sync
::
atomic
::
Ordering
;
use
syntax
::
codemap
::
Span
;
use
traits
::{
Obligation
,
ObligationCause
,
PredicateObligation
};
use
ty
::{
self
,
CanonicalVar
,
Lift
,
Region
,
Slice
,
Ty
,
TyCtxt
,
TypeFlags
};
use
ty
::
subst
::{
Kind
,
UnpackedKind
};
use
ty
::
fold
::{
TypeFoldable
,
TypeFolder
};
use
util
::
captures
::
Captures
;
use
util
::
common
::
CellUsizeExt
;
use
rustc_data_structures
::
indexed_vec
::
IndexVec
;
use
rustc_data_structures
::
fx
::
FxHashMap
;
...
...
@@ -473,7 +473,7 @@ pub fn canonicalize_query<V>(&self, value: &V) -> (V::Canonicalized, CanonicalVa
where
V
:
Canonicalize
<
'gcx
,
'tcx
>
,
{
self
.tcx.sess.perf_stats.queries_canonicalized
.
increment
(
);
self
.tcx.sess.perf_stats.queries_canonicalized
.
fetch_add
(
1
,
Ordering
::
Relaxed
);
Canonicalizer
::
canonicalize
(
value
,
...
...
src/librustc/session/mod.rs
浏览文件 @
7aa7198b
...
...
@@ -55,6 +55,7 @@
use
std
::
path
::{
Path
,
PathBuf
};
use
std
::
time
::
Duration
;
use
std
::
sync
::
mpsc
;
use
std
::
sync
::
atomic
::{
AtomicUsize
,
Ordering
};
mod
code_stats
;
pub
mod
config
;
...
...
@@ -165,27 +166,16 @@ pub struct Session {
}
pub
struct
PerfStats
{
/// The accumulated time needed for computing the SVH of the crate
pub
svh_time
:
Cell
<
Duration
>
,
/// The accumulated time spent on computing incr. comp. hashes
pub
incr_comp_hashes_time
:
Cell
<
Duration
>
,
/// The number of incr. comp. hash computations performed
pub
incr_comp_hashes_count
:
Cell
<
u64
>
,
/// The number of bytes hashed when computing ICH values
pub
incr_comp_bytes_hashed
:
Cell
<
u64
>
,
/// The accumulated time spent on computing symbol hashes
pub
symbol_hash_time
:
Cell
<
Duration
>
,
pub
symbol_hash_time
:
Lock
<
Duration
>
,
/// The accumulated time spent decoding def path tables from metadata
pub
decode_def_path_tables_time
:
Cell
<
Duration
>
,
pub
decode_def_path_tables_time
:
Lock
<
Duration
>
,
/// Total number of values canonicalized queries constructed.
pub
queries_canonicalized
:
Cell
<
usize
>
,
/// Number of times we canonicalized a value and found that the
/// result had already been canonicalized.
pub
canonicalized_values_allocated
:
Cell
<
usize
>
,
pub
queries_canonicalized
:
AtomicUsize
,
/// Number of times this query is invoked.
pub
normalize_ty_after_erasing_regions
:
Cell
<
usize
>
,
pub
normalize_ty_after_erasing_regions
:
AtomicUsize
,
/// Number of times this query is invoked.
pub
normalize_projection_ty
:
Cell
<
usize
>
,
pub
normalize_projection_ty
:
AtomicUsize
,
}
/// Enum to support dispatch of one-time diagnostics (in Session.diag_once)
...
...
@@ -838,47 +828,20 @@ pub fn incr_comp_session_dir_opt(&self) -> Option<cell::Ref<PathBuf>> {
}
pub
fn
print_perf_stats
(
&
self
)
{
println!
(
"Total time spent computing SVHs: {}"
,
duration_to_secs_str
(
self
.perf_stats.svh_time
.get
())
);
println!
(
"Total time spent computing incr. comp. hashes: {}"
,
duration_to_secs_str
(
self
.perf_stats.incr_comp_hashes_time
.get
())
);
println!
(
"Total number of incr. comp. hashes computed: {}"
,
self
.perf_stats.incr_comp_hashes_count
.get
()
);
println!
(
"Total number of bytes hashed for incr. comp.: {}"
,
self
.perf_stats.incr_comp_bytes_hashed
.get
()
);
if
self
.perf_stats.incr_comp_hashes_count
.get
()
!=
0
{
println!
(
"Average bytes hashed per incr. comp. HIR node: {}"
,
self
.perf_stats.incr_comp_bytes_hashed
.get
()
/
self
.perf_stats.incr_comp_hashes_count
.get
()
);
}
else
{
println!
(
"Average bytes hashed per incr. comp. HIR node: N/A"
);
}
println!
(
"Total time spent computing symbol hashes: {}"
,
duration_to_secs_str
(
self
.perf_stats.symbol_hash_time
.get
())
duration_to_secs_str
(
*
self
.perf_stats.symbol_hash_time
.lock
())
);
println!
(
"Total time spent decoding DefPath tables: {}"
,
duration_to_secs_str
(
self
.perf_stats.decode_def_path_tables_time
.get
())
duration_to_secs_str
(
*
self
.perf_stats.decode_def_path_tables_time
.lock
())
);
println!
(
"Total queries canonicalized: {}"
,
self
.perf_stats.queries_canonicalized
.get
());
println!
(
"Total canonical values interned: {}"
,
self
.perf_stats.canonicalized_values_allocated
.get
());
self
.perf_stats.queries_canonicalized
.load
(
Ordering
::
Relaxed
));
println!
(
"normalize_ty_after_erasing_regions: {}"
,
self
.perf_stats.normalize_ty_after_erasing_regions
.
get
(
));
self
.perf_stats.normalize_ty_after_erasing_regions
.
load
(
Ordering
::
Relaxed
));
println!
(
"normalize_projection_ty: {}"
,
self
.perf_stats.normalize_projection_ty
.
get
(
));
self
.perf_stats.normalize_projection_ty
.
load
(
Ordering
::
Relaxed
));
}
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
...
...
@@ -1160,16 +1123,11 @@ pub fn build_session_(
ignored_attr_names
:
ich
::
compute_ignored_attr_names
(),
profile_channel
:
Lock
::
new
(
None
),
perf_stats
:
PerfStats
{
svh_time
:
Cell
::
new
(
Duration
::
from_secs
(
0
)),
incr_comp_hashes_time
:
Cell
::
new
(
Duration
::
from_secs
(
0
)),
incr_comp_hashes_count
:
Cell
::
new
(
0
),
incr_comp_bytes_hashed
:
Cell
::
new
(
0
),
symbol_hash_time
:
Cell
::
new
(
Duration
::
from_secs
(
0
)),
decode_def_path_tables_time
:
Cell
::
new
(
Duration
::
from_secs
(
0
)),
queries_canonicalized
:
Cell
::
new
(
0
),
canonicalized_values_allocated
:
Cell
::
new
(
0
),
normalize_ty_after_erasing_regions
:
Cell
::
new
(
0
),
normalize_projection_ty
:
Cell
::
new
(
0
),
symbol_hash_time
:
Lock
::
new
(
Duration
::
from_secs
(
0
)),
decode_def_path_tables_time
:
Lock
::
new
(
Duration
::
from_secs
(
0
)),
queries_canonicalized
:
AtomicUsize
::
new
(
0
),
normalize_ty_after_erasing_regions
:
AtomicUsize
::
new
(
0
),
normalize_projection_ty
:
AtomicUsize
::
new
(
0
),
},
code_stats
:
RefCell
::
new
(
CodeStats
::
new
()),
optimization_fuel_crate
,
...
...
src/librustc/util/common.rs
浏览文件 @
7aa7198b
...
...
@@ -10,6 +10,8 @@
#![allow(non_camel_case_types)]
use
rustc_data_structures
::
sync
::
Lock
;
use
std
::
cell
::{
RefCell
,
Cell
};
use
std
::
collections
::
HashMap
;
use
std
::
ffi
::
CString
;
...
...
@@ -236,13 +238,14 @@ pub fn to_readable_str(mut val: usize) -> String {
groups
.join
(
"_"
)
}
pub
fn
record_time
<
T
,
F
>
(
accu
:
&
Cell
<
Duration
>
,
f
:
F
)
->
T
where
pub
fn
record_time
<
T
,
F
>
(
accu
:
&
Lock
<
Duration
>
,
f
:
F
)
->
T
where
F
:
FnOnce
()
->
T
,
{
let
start
=
Instant
::
now
();
let
rv
=
f
();
let
duration
=
start
.elapsed
();
accu
.set
(
duration
+
accu
.get
());
let
mut
accu
=
accu
.lock
();
*
accu
=
*
accu
+
duration
;
rv
}
...
...
@@ -382,13 +385,3 @@ fn test_to_readable_str() {
assert_eq!
(
"1_000_000"
,
to_readable_str
(
1_000_000
));
assert_eq!
(
"1_234_567"
,
to_readable_str
(
1_234_567
));
}
pub
trait
CellUsizeExt
{
fn
increment
(
&
self
);
}
impl
CellUsizeExt
for
Cell
<
usize
>
{
fn
increment
(
&
self
)
{
self
.set
(
self
.get
()
+
1
);
}
}
src/librustc_traits/normalize_erasing_regions.rs
浏览文件 @
7aa7198b
...
...
@@ -11,17 +11,14 @@
use
rustc
::
traits
::{
Normalized
,
ObligationCause
};
use
rustc
::
traits
::
query
::
NoSolution
;
use
rustc
::
ty
::{
self
,
ParamEnvAnd
,
Ty
,
TyCtxt
};
use
rustc
::
util
::
common
::
CellUsizeExt
;
use
std
::
sync
::
atomic
::
Ordering
;
crate
fn
normalize_ty_after_erasing_regions
<
'tcx
>
(
tcx
:
TyCtxt
<
'_
,
'tcx
,
'tcx
>
,
goal
:
ParamEnvAnd
<
'tcx
,
Ty
<
'tcx
>>
,
)
->
Ty
<
'tcx
>
{
let
ParamEnvAnd
{
param_env
,
value
}
=
goal
;
tcx
.sess
.perf_stats
.normalize_ty_after_erasing_regions
.increment
();
tcx
.sess.perf_stats.normalize_ty_after_erasing_regions
.fetch_add
(
1
,
Ordering
::
Relaxed
);
tcx
.infer_ctxt
()
.enter
(|
infcx
|
{
let
cause
=
ObligationCause
::
dummy
();
match
infcx
.at
(
&
cause
,
param_env
)
.normalize
(
&
value
)
{
...
...
src/librustc_traits/normalize_projection_ty.rs
浏览文件 @
7aa7198b
...
...
@@ -13,11 +13,11 @@
SelectionContext
};
use
rustc
::
traits
::
query
::{
CanonicalProjectionGoal
,
NoSolution
,
normalize
::
NormalizationResult
};
use
rustc
::
ty
::{
ParamEnvAnd
,
TyCtxt
};
use
rustc
::
util
::
common
::
CellUsizeExt
;
use
rustc_data_structures
::
sync
::
Lrc
;
use
syntax
::
ast
::
DUMMY_NODE_ID
;
use
syntax_pos
::
DUMMY_SP
;
use
util
;
use
std
::
sync
::
atomic
::
Ordering
;
crate
fn
normalize_projection_ty
<
'tcx
>
(
tcx
:
TyCtxt
<
'_
,
'tcx
,
'tcx
>
,
...
...
@@ -25,7 +25,7 @@
)
->
Result
<
Lrc
<
Canonical
<
'tcx
,
QueryResult
<
'tcx
,
NormalizationResult
<
'tcx
>>>>
,
NoSolution
>
{
debug!
(
"normalize_provider(goal={:#?})"
,
goal
);
tcx
.sess.perf_stats.normalize_projection_ty
.
increment
(
);
tcx
.sess.perf_stats.normalize_projection_ty
.
fetch_add
(
1
,
Ordering
::
Relaxed
);
tcx
.infer_ctxt
()
.enter
(|
ref
infcx
|
{
let
(
ParamEnvAnd
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录