Delete query stats
These statistics are computable from the self-profile data and/or ad-hoc collectable as needed, and in the meantime contribute to rustc bootstrap times.
This commit is contained in:
parent
88fb06a1f3
commit
257839bd88
5 changed files with 0 additions and 122 deletions
|
@ -403,10 +403,6 @@ impl Compiler {
|
||||||
gcx.enter(rustc_query_impl::alloc_self_profile_query_strings);
|
gcx.enter(rustc_query_impl::alloc_self_profile_query_strings);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.session().opts.debugging_opts.query_stats {
|
|
||||||
gcx.enter(rustc_query_impl::print_stats);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.session()
|
self.session()
|
||||||
.time("serialize_dep_graph", || gcx.enter(rustc_incremental::save_dep_graph));
|
.time("serialize_dep_graph", || gcx.enter(rustc_incremental::save_dep_graph));
|
||||||
}
|
}
|
||||||
|
|
|
@ -684,7 +684,6 @@ fn test_debugging_options_tracking_hash() {
|
||||||
untracked!(print_type_sizes, true);
|
untracked!(print_type_sizes, true);
|
||||||
untracked!(proc_macro_backtrace, true);
|
untracked!(proc_macro_backtrace, true);
|
||||||
untracked!(query_dep_graph, true);
|
untracked!(query_dep_graph, true);
|
||||||
untracked!(query_stats, true);
|
|
||||||
untracked!(save_analysis, true);
|
untracked!(save_analysis, true);
|
||||||
untracked!(self_profile, SwitchWithOptPath::Enabled(None));
|
untracked!(self_profile, SwitchWithOptPath::Enabled(None));
|
||||||
untracked!(self_profile_events, Some(vec![String::new()]));
|
untracked!(self_profile_events, Some(vec![String::new()]));
|
||||||
|
|
|
@ -28,9 +28,6 @@ mod plumbing;
|
||||||
pub use plumbing::QueryCtxt;
|
pub use plumbing::QueryCtxt;
|
||||||
use rustc_query_system::query::*;
|
use rustc_query_system::query::*;
|
||||||
|
|
||||||
mod stats;
|
|
||||||
pub use self::stats::print_stats;
|
|
||||||
|
|
||||||
mod keys;
|
mod keys;
|
||||||
use keys::Key;
|
use keys::Key;
|
||||||
|
|
||||||
|
|
|
@ -1,112 +0,0 @@
|
||||||
use rustc_hir::def_id::{DefId, LOCAL_CRATE};
|
|
||||||
use rustc_middle::ty::query::query_storage;
|
|
||||||
use rustc_middle::ty::TyCtxt;
|
|
||||||
use rustc_query_system::query::{QueryCache, QueryCacheStore};
|
|
||||||
|
|
||||||
use std::any::type_name;
|
|
||||||
use std::mem;
|
|
||||||
|
|
||||||
trait KeyStats {
|
|
||||||
fn key_stats(&self, stats: &mut QueryStats);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> KeyStats for T {
|
|
||||||
default fn key_stats(&self, _: &mut QueryStats) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl KeyStats for DefId {
|
|
||||||
fn key_stats(&self, stats: &mut QueryStats) {
|
|
||||||
if self.krate == LOCAL_CRATE {
|
|
||||||
stats.local_def_id_keys = Some(stats.local_def_id_keys.unwrap_or(0) + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone)]
|
|
||||||
struct QueryStats {
|
|
||||||
name: &'static str,
|
|
||||||
key_size: usize,
|
|
||||||
key_type: &'static str,
|
|
||||||
value_size: usize,
|
|
||||||
value_type: &'static str,
|
|
||||||
entry_count: usize,
|
|
||||||
local_def_id_keys: Option<usize>,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn stats<C>(name: &'static str, map: &QueryCacheStore<C>) -> QueryStats
|
|
||||||
where
|
|
||||||
C: QueryCache,
|
|
||||||
{
|
|
||||||
let mut stats = QueryStats {
|
|
||||||
name,
|
|
||||||
key_size: mem::size_of::<C::Key>(),
|
|
||||||
key_type: type_name::<C::Key>(),
|
|
||||||
value_size: mem::size_of::<C::Value>(),
|
|
||||||
value_type: type_name::<C::Value>(),
|
|
||||||
entry_count: 0,
|
|
||||||
local_def_id_keys: None,
|
|
||||||
};
|
|
||||||
map.iter_results(&mut |key, _, _| {
|
|
||||||
stats.entry_count += 1;
|
|
||||||
key.key_stats(&mut stats)
|
|
||||||
});
|
|
||||||
stats
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn print_stats(tcx: TyCtxt<'_>) {
|
|
||||||
let queries = query_stats(tcx);
|
|
||||||
|
|
||||||
let mut query_key_sizes = queries.clone();
|
|
||||||
query_key_sizes.sort_by_key(|q| q.key_size);
|
|
||||||
eprintln!("\nLarge query keys:");
|
|
||||||
for q in query_key_sizes.iter().rev().filter(|q| q.key_size > 8) {
|
|
||||||
eprintln!(" {} - {} x {} - {}", q.name, q.key_size, q.entry_count, q.key_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut query_value_sizes = queries.clone();
|
|
||||||
query_value_sizes.sort_by_key(|q| q.value_size);
|
|
||||||
eprintln!("\nLarge query values:");
|
|
||||||
for q in query_value_sizes.iter().rev().filter(|q| q.value_size > 8) {
|
|
||||||
eprintln!(" {} - {} x {} - {}", q.name, q.value_size, q.entry_count, q.value_type);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut query_value_count = queries.clone();
|
|
||||||
query_value_count.sort_by_key(|q| q.entry_count);
|
|
||||||
eprintln!("\nQuery value count:");
|
|
||||||
for q in query_value_count.iter().rev() {
|
|
||||||
eprintln!(" {} - {}", q.name, q.entry_count);
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut def_id_density: Vec<_> =
|
|
||||||
queries.iter().filter(|q| q.local_def_id_keys.is_some()).collect();
|
|
||||||
def_id_density.sort_by_key(|q| q.local_def_id_keys.unwrap());
|
|
||||||
eprintln!("\nLocal DefId density:");
|
|
||||||
let total = tcx.resolutions(()).definitions.def_index_count() as f64;
|
|
||||||
for q in def_id_density.iter().rev() {
|
|
||||||
let local = q.local_def_id_keys.unwrap();
|
|
||||||
eprintln!(" {} - {} = ({}%)", q.name, local, (local as f64 * 100.0) / total);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! print_stats {
|
|
||||||
(<$tcx:tt>
|
|
||||||
$($(#[$attr:meta])* [$($modifiers:tt)*] fn $name:ident($K:ty) -> $V:ty,)*
|
|
||||||
) => {
|
|
||||||
fn query_stats(tcx: TyCtxt<'_>) -> Vec<QueryStats> {
|
|
||||||
let mut queries = Vec::new();
|
|
||||||
|
|
||||||
$(
|
|
||||||
queries.push(stats::<
|
|
||||||
query_storage::$name<'_>,
|
|
||||||
>(
|
|
||||||
stringify!($name),
|
|
||||||
&tcx.query_caches.$name,
|
|
||||||
));
|
|
||||||
)*
|
|
||||||
|
|
||||||
queries
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rustc_query_append! { [print_stats!][<'tcx>] }
|
|
|
@ -1367,8 +1367,6 @@ options! {
|
||||||
"use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
|
"use the given `.prof` file for sampled profile-guided optimization (also known as AutoFDO)"),
|
||||||
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
|
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
|
||||||
"enable queries of the dependency graph for regression testing (default: no)"),
|
"enable queries of the dependency graph for regression testing (default: no)"),
|
||||||
query_stats: bool = (false, parse_bool, [UNTRACKED],
|
|
||||||
"print some statistics about the query system (default: no)"),
|
|
||||||
randomize_layout: bool = (false, parse_bool, [TRACKED],
|
randomize_layout: bool = (false, parse_bool, [TRACKED],
|
||||||
"randomize the layout of types (default: no)"),
|
"randomize the layout of types (default: no)"),
|
||||||
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
|
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue