mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-22 05:24:48 +00:00
Auto merge of #45063 - michaelwoerister:bring-back-incremental-info, r=nikomatsakis
incr.comp.: Bring back output of -Zincremental-info. This got kind lost during the transition to red/green. I also switched back from `eprintln!()` to `println!()` since the former never actually produced any output. I suspect this has to do with `libterm` somehow monopolizing `stderr`. r? @nikomatsakis
This commit is contained in:
commit
305e02281b
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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<bool, ()> {
|
||||
// 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)
|
||||
|
@ -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");
|
||||
|
@ -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<f64> = counts.iter().map(|s| {
|
||||
(100.0 * (s.node_counter as f64)) / (total_node_count as f64)
|
||||
}).collect();
|
||||
|
||||
let average_edges_per_kind: Vec<f64> = 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(())
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user