diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 54a3dbafe27..e91acb21dac 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -129,10 +129,6 @@ fn main() { // Pass down incremental directory, if any. if let Ok(dir) = env::var("RUSTC_INCREMENTAL") { cmd.arg(format!("-Zincremental={}", dir)); - - if verbose > 0 { - cmd.arg("-Zincremental-info"); - } } let crate_name = args.windows(2) diff --git a/src/librustc_incremental/persist/file_format.rs b/src/librustc_incremental/persist/file_format.rs index 13b019af2ea..7d1400b6b95 100644 --- a/src/librustc_incremental/persist/file_format.rs +++ b/src/librustc_incremental/persist/file_format.rs @@ -117,7 +117,7 @@ fn report_format_mismatch(sess: &Session, file: &Path, message: &str) { debug!("read_file: {}", message); if sess.opts.debugging_opts.incremental_info { - eprintln!("incremental: ignoring cache artifact `{}`: {}", + println!("[incremental] ignoring cache artifact `{}`: {}", file.file_name().unwrap().to_string_lossy(), message); } diff --git a/src/librustc_incremental/persist/fs.rs b/src/librustc_incremental/persist/fs.rs index 9b12b755581..d53ee5c804f 100644 --- a/src/librustc_incremental/persist/fs.rs +++ b/src/librustc_incremental/persist/fs.rs @@ -256,11 +256,12 @@ pub fn prepare_session_directory(sess: &Session, debug!("attempting to copy data from source: {}", source_directory.display()); - let print_file_copy_stats = sess.opts.debugging_opts.incremental_info; + // Try copying over all files from the source directory - if let Ok(allows_links) = copy_files(&session_dir, &source_directory, - print_file_copy_stats) { + if let Ok(allows_links) = copy_files(sess, + &session_dir, + &source_directory) { debug!("successfully copied data from: {}", source_directory.display()); @@ -390,9 +391,9 @@ pub fn delete_all_session_dir_contents(sess: &Session) -> io::Result<()> { Ok(()) } -fn copy_files(target_dir: &Path, - source_dir: &Path, - print_stats_on_success: bool) +fn copy_files(sess: &Session, + target_dir: &Path, + source_dir: &Path) -> Result { // We acquire a shared lock on the lock file of the directory, so that // nobody deletes it out from under us while we are reading from it. @@ -440,9 +441,11 @@ fn copy_files(target_dir: &Path, } } - if print_stats_on_success { - eprintln!("incremental: session directory: {} files hard-linked", files_linked); - eprintln!("incremental: session directory: {} files copied", files_copied); + if sess.opts.debugging_opts.incremental_info { + println!("[incremental] session directory: \ + {} files hard-linked", files_linked); + println!("[incremental] session directory: \ + {} files copied", files_copied); } Ok(files_linked > 0 || files_copied == 0) diff --git a/src/librustc_incremental/persist/load.rs b/src/librustc_incremental/persist/load.rs index cdfc9f2edc3..63cfbcac145 100644 --- a/src/librustc_incremental/persist/load.rs +++ b/src/librustc_incremental/persist/load.rs @@ -177,8 +177,8 @@ pub fn load_dep_graph(sess: &Session) -> PreviousDepGraph { if prev_commandline_args_hash != sess.opts.dep_tracking_hash() { if sess.opts.debugging_opts.incremental_info { - eprintln!("incremental: completely ignoring cache because of \ - differing commandline arguments"); + println!("[incremental] completely ignoring cache because of \ + differing commandline arguments"); } // We can't reuse the cache, purge it. debug!("load_dep_graph_new: differing commandline arg hashes"); diff --git a/src/librustc_incremental/persist/save.rs b/src/librustc_incremental/persist/save.rs index 4919870fcd5..b9f73500e27 100644 --- a/src/librustc_incremental/persist/save.rs +++ b/src/librustc_incremental/persist/save.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use rustc::dep_graph::DepGraph; +use rustc::dep_graph::{DepGraph, DepKind}; use rustc::hir::def_id::DefId; use rustc::hir::svh::Svh; use rustc::ich::Fingerprint; @@ -170,6 +170,77 @@ fn encode_dep_graph(tcx: TyCtxt, // Encode the graph data. let serialized_graph = tcx.dep_graph.serialize(); + + if tcx.sess.opts.debugging_opts.incremental_info { + #[derive(Clone)] + struct Stat { + kind: DepKind, + node_counter: u64, + edge_counter: u64, + } + + let total_node_count = serialized_graph.nodes.len(); + let total_edge_count = serialized_graph.edge_list_data.len(); + + let mut counts: FxHashMap<_, Stat> = FxHashMap(); + + for (i, &(node, _)) in serialized_graph.nodes.iter_enumerated() { + let stat = counts.entry(node.kind).or_insert(Stat { + kind: node.kind, + node_counter: 0, + edge_counter: 0, + }); + + stat.node_counter += 1; + let (edge_start, edge_end) = serialized_graph.edge_list_indices[i]; + stat.edge_counter += (edge_end - edge_start) as u64; + } + + let mut counts: Vec<_> = counts.values().cloned().collect(); + counts.sort_by_key(|s| -(s.node_counter as i64)); + + let percentage_of_all_nodes: Vec = counts.iter().map(|s| { + (100.0 * (s.node_counter as f64)) / (total_node_count as f64) + }).collect(); + + let average_edges_per_kind: Vec = counts.iter().map(|s| { + (s.edge_counter as f64) / (s.node_counter as f64) + }).collect(); + + println!("[incremental]"); + println!("[incremental] DepGraph Statistics"); + + const SEPARATOR: &str = "[incremental] --------------------------------\ + ----------------------------------------------\ + ------------"; + + println!("{}", SEPARATOR); + println!("[incremental]"); + println!("[incremental] Total Node Count: {}", total_node_count); + println!("[incremental] Total Edge Count: {}", total_edge_count); + println!("[incremental]"); + println!("[incremental] {:<36}| {:<17}| {:<12}| {:<17}|", + "Node Kind", + "Node Frequency", + "Node Count", + "Avg. Edge Count"); + println!("[incremental] -------------------------------------\ + |------------------\ + |-------------\ + |------------------|"); + + for (i, stat) in counts.iter().enumerate() { + println!("[incremental] {:<36}|{:>16.1}% |{:>12} |{:>17.1} |", + format!("{:?}", stat.kind), + percentage_of_all_nodes[i], + stat.node_counter, + average_edges_per_kind[i]); + } + + println!("{}", SEPARATOR); + println!("[incremental]"); + } + serialized_graph.encode(encoder)?; Ok(()) diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 6ebf642ebca..9d914243ec6 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -1079,13 +1079,9 @@ fn produce_final_output_artifacts(sess: &Session, } pub fn dump_incremental_data(trans: &CrateTranslation) { - let mut reuse = 0; - for mtrans in trans.modules.iter() { - if mtrans.pre_existing { - reuse += 1; - } - } - eprintln!("incremental: re-using {} out of {} modules", reuse, trans.modules.len()); + println!("[incremental] Re-using {} out of {} modules", + trans.modules.iter().filter(|m| m.pre_existing).count(), + trans.modules.len()); } enum WorkItem { diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 870e08cc6e5..dfdbabdcd4a 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2028,7 +2028,6 @@ actual:\n\ // Add an extra flag pointing at the incremental directory. let mut revision_props = self.props.clone(); revision_props.incremental_dir = Some(incremental_dir); - revision_props.compile_flags.push(String::from("-Zincremental-info")); let revision_cx = TestCx { config: self.config,