Skip to content

Commit e0d2629

Browse files
definitions: Add some timing stats for DefPathTable decoding.
1 parent ed5a88e commit e0d2629

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/librustc/session/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ pub struct PerfStats {
136136
pub incr_comp_bytes_hashed: Cell<u64>,
137137
// The accumulated time spent on computing symbol hashes
138138
pub symbol_hash_time: Cell<Duration>,
139+
// The accumulated time spent decoding def path tables from metadata
140+
pub decode_def_path_tables_time: Cell<Duration>,
139141
}
140142

141143
impl Session {
@@ -501,6 +503,8 @@ impl Session {
501503
self.perf_stats.incr_comp_hashes_count.get());
502504
println!("Total time spent computing symbol hashes: {}",
503505
duration_to_secs_str(self.perf_stats.symbol_hash_time.get()));
506+
println!("Total time spent decoding DefPath tables: {}",
507+
duration_to_secs_str(self.perf_stats.decode_def_path_tables_time.get()));
504508
}
505509
}
506510

@@ -635,6 +639,7 @@ pub fn build_session_(sopts: config::Options,
635639
incr_comp_hashes_count: Cell::new(0),
636640
incr_comp_bytes_hashed: Cell::new(0),
637641
symbol_hash_time: Cell::new(Duration::from_secs(0)),
642+
decode_def_path_tables_time: Cell::new(Duration::from_secs(0)),
638643
},
639644
code_stats: RefCell::new(CodeStats::new()),
640645
};

src/librustc_metadata/creader.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use rustc_back::PanicStrategy;
2222
use rustc::session::search_paths::PathKind;
2323
use rustc::middle;
2424
use rustc::middle::cstore::{CrateStore, validate_crate_name, ExternCrate};
25+
use rustc::util::common::record_time;
2526
use rustc::util::nodemap::FxHashSet;
2627
use rustc::middle::cstore::NativeLibrary;
2728
use rustc::hir::map::Definitions;
@@ -297,10 +298,14 @@ impl<'a> CrateLoader<'a> {
297298

298299
let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span, dep_kind);
299300

301+
let def_path_table = record_time(&self.sess.perf_stats.decode_def_path_tables_time, || {
302+
crate_root.def_path_table.decode(&metadata)
303+
});
304+
300305
let mut cmeta = cstore::CrateMetadata {
301306
name: name,
302307
extern_crate: Cell::new(None),
303-
def_path_table: crate_root.def_path_table.decode(&metadata),
308+
def_path_table: def_path_table,
304309
proc_macros: crate_root.macro_derive_registrar.map(|_| {
305310
self.load_derive_macros(&crate_root, dylib.clone().map(|p| p.0), span)
306311
}),

0 commit comments

Comments
 (0)