Skip to content

Commit ead5cf1

Browse files
committed
Add misc timings
1 parent e3e4420 commit ead5cf1

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

src/librustc/ty/maps/on_disk_cache.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use ty;
3333
use ty::maps::job::QueryResult;
3434
use ty::codec::{self as ty_codec, TyDecoder, TyEncoder};
3535
use ty::context::TyCtxt;
36+
use util::common::time;
3637

3738
const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE;
3839

@@ -214,7 +215,7 @@ impl<'sess> OnDiskCache<'sess> {
214215
// Encode query results
215216
let mut query_result_index = EncodedQueryResultIndex::new();
216217

217-
{
218+
time(tcx.sess, "encode query results", || {
218219
use ty::maps::queries::*;
219220
let enc = &mut encoder;
220221
let qri = &mut query_result_index;
@@ -258,7 +259,9 @@ impl<'sess> OnDiskCache<'sess> {
258259
}
259260
}
260261
}
261-
}
262+
263+
Ok(())
264+
})?;
262265

263266
// Encode diagnostics
264267
let diagnostics_index = {
@@ -1125,6 +1128,11 @@ fn encode_query_results<'enc, 'a, 'tcx, Q, E>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11251128
E: 'enc + TyEncoder,
11261129
Q::Value: Encodable,
11271130
{
1131+
let desc = &format!("encode_query_results for {}",
1132+
unsafe { ::std::intrinsics::type_name::<Q>() });
1133+
1134+
time(tcx.sess, desc, || {
1135+
11281136
for (key, entry) in Q::get_cache_internal(tcx).map.iter() {
11291137
if Q::cache_on_disk(key.clone()) {
11301138
let entry = match *entry {
@@ -1143,4 +1151,5 @@ fn encode_query_results<'enc, 'a, 'tcx, Q, E>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11431151
}
11441152

11451153
Ok(())
1154+
})
11461155
}

src/librustc_driver/driver.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,9 +793,13 @@ pub fn phase_2_configure_and_expand_inner<'a, F>(sess: &'a Session,
793793
let mut ecx = ExtCtxt::new(&sess.parse_sess, cfg, &mut resolver);
794794
let err_count = ecx.parse_sess.span_diagnostic.err_count();
795795

796-
let krate = ecx.monotonic_expander().expand_crate(krate);
796+
let krate = time(sess, "expand crate", || {
797+
ecx.monotonic_expander().expand_crate(krate)
798+
});
797799

798-
ecx.check_unused_macros();
800+
time(sess, "check unused macros", || {
801+
ecx.check_unused_macros();
802+
});
799803

800804
let mut missing_fragment_specifiers: Vec<_> =
801805
ecx.parse_sess.missing_fragment_specifiers.borrow().iter().cloned().collect();

src/librustc_incremental/persist/save.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ pub fn save_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
4343
time(sess, "persist dep-graph", || {
4444
save_in(sess,
4545
dep_graph_path(sess),
46-
|e| encode_dep_graph(tcx, e));
46+
|e| {
47+
time(sess, "encode dep-graph", || {
48+
encode_dep_graph(tcx, e)
49+
})
50+
});
4751
});
4852
}
4953

@@ -145,7 +149,9 @@ fn encode_dep_graph(tcx: TyCtxt,
145149
tcx.sess.opts.dep_tracking_hash().encode(encoder)?;
146150

147151
// Encode the graph data.
148-
let serialized_graph = tcx.dep_graph.serialize();
152+
let serialized_graph = time(tcx.sess, "getting serialized graph", || {
153+
tcx.dep_graph.serialize()
154+
});
149155

150156
if tcx.sess.opts.debugging_opts.incremental_info {
151157
#[derive(Clone)]
@@ -221,7 +227,9 @@ fn encode_dep_graph(tcx: TyCtxt,
221227
println!("[incremental]");
222228
}
223229

224-
serialized_graph.encode(encoder)?;
230+
time(tcx.sess, "encoding serialized graph", || {
231+
serialized_graph.encode(encoder)
232+
})?;
225233

226234
Ok(())
227235
}
@@ -245,5 +253,7 @@ fn encode_work_products(dep_graph: &DepGraph,
245253
fn encode_query_cache(tcx: TyCtxt,
246254
encoder: &mut Encoder)
247255
-> io::Result<()> {
248-
tcx.serialize_query_result_cache(encoder)
256+
time(tcx.sess, "serialize query result cache", || {
257+
tcx.serialize_query_result_cache(encoder)
258+
})
249259
}

0 commit comments

Comments
 (0)