Skip to content

Commit d5375d0

Browse files
committed
Auto merge of rust-lang#117773 - nnethercote:rm-Zperf-stats, r=wesleywiser
Remove `-Zperf-stats`. The included measurements have varied over the years. At one point there were quite a few more, but rust-lang#49558 deleted a lot that were no longer used. Today there's just four, and it's a motley collection that doesn't seem particularly valuable. I think it has been well and truly subsumed by self-profiling, which collects way more data. r? `@wesleywiser`
2 parents b917524 + aefbb61 commit d5375d0

File tree

8 files changed

+31
-99
lines changed

8 files changed

+31
-99
lines changed

compiler/rustc_driver_impl/src/lib.rs

-4
Original file line numberDiff line numberDiff line change
@@ -496,10 +496,6 @@ fn run_compiler(
496496
linker.link()?
497497
}
498498

499-
if sess.opts.unstable_opts.perf_stats {
500-
sess.print_perf_stats();
501-
}
502-
503499
if sess.opts.unstable_opts.print_fuel.is_some() {
504500
eprintln!(
505501
"Fuel used by {}: {}",

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use rustc_middle::ty::flags::FlagComputation;
1313
use rustc_middle::ty::fold::{TypeFoldable, TypeFolder, TypeSuperFoldable};
1414
use rustc_middle::ty::GenericArg;
1515
use rustc_middle::ty::{self, BoundVar, InferConst, List, Ty, TyCtxt, TypeFlags, TypeVisitableExt};
16-
use std::sync::atomic::Ordering;
1716

1817
use rustc_data_structures::fx::FxHashMap;
1918
use rustc_index::Idx;
@@ -43,8 +42,6 @@ impl<'tcx> InferCtxt<'tcx> {
4342
where
4443
V: TypeFoldable<TyCtxt<'tcx>>,
4544
{
46-
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
47-
4845
Canonicalizer::canonicalize(value, self, self.tcx, &CanonicalizeAllFreeRegions, query_state)
4946
}
5047

@@ -62,8 +59,6 @@ impl<'tcx> InferCtxt<'tcx> {
6259
where
6360
V: TypeFoldable<TyCtxt<'tcx>>,
6461
{
65-
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
66-
6762
Canonicalizer::canonicalize(
6863
value,
6964
self,
@@ -138,8 +133,6 @@ impl<'tcx> InferCtxt<'tcx> {
138133
where
139134
V: TypeFoldable<TyCtxt<'tcx>>,
140135
{
141-
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
142-
143136
Canonicalizer::canonicalize(
144137
value,
145138
self,

compiler/rustc_interface/src/tests.rs

-1
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,6 @@ fn test_unstable_options_tracking_hash() {
690690
untracked!(no_leak_check, true);
691691
untracked!(no_parallel_llvm, true);
692692
untracked!(parse_only, true);
693-
untracked!(perf_stats, true);
694693
// `pre_link_arg` is omitted because it just forwards to `pre_link_args`.
695694
untracked!(pre_link_args, vec![String::from("abc"), String::from("def")]);
696695
untracked!(print_codegen_stats, true);

compiler/rustc_session/src/options.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1708,8 +1708,6 @@ options! {
17081708
"panic strategy for panics in drops"),
17091709
parse_only: bool = (false, parse_bool, [UNTRACKED],
17101710
"parse only; do not compile, assemble, or link (default: no)"),
1711-
perf_stats: bool = (false, parse_bool, [UNTRACKED],
1712-
"print some performance-related statistics (default: no)"),
17131711
plt: Option<bool> = (None, parse_opt_bool, [TRACKED],
17141712
"whether to use the PLT when calling into shared libraries;
17151713
only has effect for PIC code on systems with ELF binaries

compiler/rustc_session/src/session.rs

+2-44
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ pub use rustc_ast::Attribute;
1515
use rustc_data_structures::flock;
1616
use rustc_data_structures::fx::{FxHashMap, FxIndexSet};
1717
use rustc_data_structures::jobserver::{self, Client};
18-
use rustc_data_structures::profiling::{duration_to_secs_str, SelfProfiler, SelfProfilerRef};
19-
use rustc_data_structures::sync::{
20-
AtomicU64, AtomicUsize, Lock, Lrc, OneThread, Ordering, Ordering::SeqCst,
21-
};
18+
use rustc_data_structures::profiling::{SelfProfiler, SelfProfilerRef};
19+
use rustc_data_structures::sync::{AtomicU64, Lock, Lrc, OneThread, Ordering::SeqCst};
2220
use rustc_errors::annotate_snippet_emitter_writer::AnnotateSnippetEmitterWriter;
2321
use rustc_errors::emitter::{DynEmitter, EmitterWriter, HumanReadableErrorType};
2422
use rustc_errors::json::JsonEmitter;
@@ -46,7 +44,6 @@ use std::ops::{Div, Mul};
4644
use std::path::{Path, PathBuf};
4745
use std::str::FromStr;
4846
use std::sync::{atomic::AtomicBool, Arc};
49-
use std::time::Duration;
5047

5148
pub struct OptimizationFuel {
5249
/// If `-zfuel=crate=n` is specified, initially set to `n`, otherwise `0`.
@@ -157,9 +154,6 @@ pub struct Session {
157154
/// Used by `-Z self-profile`.
158155
pub prof: SelfProfilerRef,
159156

160-
/// Some measurements that are being gathered during compilation.
161-
pub perf_stats: PerfStats,
162-
163157
/// Data about code being compiled, gathered during compilation.
164158
pub code_stats: CodeStats,
165159

@@ -215,17 +209,6 @@ pub struct Session {
215209
pub expanded_args: Vec<String>,
216210
}
217211

218-
pub struct PerfStats {
219-
/// The accumulated time spent on computing symbol hashes.
220-
pub symbol_hash_time: Lock<Duration>,
221-
/// Total number of values canonicalized queries constructed.
222-
pub queries_canonicalized: AtomicUsize,
223-
/// Number of times this query is invoked.
224-
pub normalize_generic_arg_after_erasing_regions: AtomicUsize,
225-
/// Number of times this query is invoked.
226-
pub normalize_projection_ty: AtomicUsize,
227-
}
228-
229212
#[derive(PartialEq, Eq, PartialOrd, Ord)]
230213
pub enum MetadataKind {
231214
None,
@@ -883,25 +866,6 @@ impl Session {
883866
self.opts.incremental.as_ref().map(|_| self.incr_comp_session_dir())
884867
}
885868

886-
pub fn print_perf_stats(&self) {
887-
eprintln!(
888-
"Total time spent computing symbol hashes: {}",
889-
duration_to_secs_str(*self.perf_stats.symbol_hash_time.lock())
890-
);
891-
eprintln!(
892-
"Total queries canonicalized: {}",
893-
self.perf_stats.queries_canonicalized.load(Ordering::Relaxed)
894-
);
895-
eprintln!(
896-
"normalize_generic_arg_after_erasing_regions: {}",
897-
self.perf_stats.normalize_generic_arg_after_erasing_regions.load(Ordering::Relaxed)
898-
);
899-
eprintln!(
900-
"normalize_projection_ty: {}",
901-
self.perf_stats.normalize_projection_ty.load(Ordering::Relaxed)
902-
);
903-
}
904-
905869
/// We want to know if we're allowed to do an optimization for crate foo from -z fuel=foo=n.
906870
/// This expends fuel if applicable, and records fuel if applicable.
907871
pub fn consider_optimizing(
@@ -1515,12 +1479,6 @@ pub fn build_session(
15151479
io,
15161480
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
15171481
prof,
1518-
perf_stats: PerfStats {
1519-
symbol_hash_time: Lock::new(Duration::from_secs(0)),
1520-
queries_canonicalized: AtomicUsize::new(0),
1521-
normalize_generic_arg_after_erasing_regions: AtomicUsize::new(0),
1522-
normalize_projection_ty: AtomicUsize::new(0),
1523-
},
15241482
code_stats: Default::default(),
15251483
optimization_fuel,
15261484
print_fuel,

compiler/rustc_symbol_mangling/src/legacy.rs

+29-32
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
44
use rustc_middle::ty::print::{PrettyPrinter, Print, PrintError, Printer};
55
use rustc_middle::ty::{self, Instance, Ty, TyCtxt, TypeVisitableExt};
66
use rustc_middle::ty::{GenericArg, GenericArgKind};
7-
use rustc_middle::util::common::record_time;
87

98
use std::fmt::{self, Write};
109
use std::mem::{self, discriminant};
@@ -101,40 +100,38 @@ fn get_symbol_hash<'tcx>(
101100
tcx.with_stable_hashing_context(|mut hcx| {
102101
let mut hasher = StableHasher::new();
103102

104-
record_time(&tcx.sess.perf_stats.symbol_hash_time, || {
105-
// the main symbol name is not necessarily unique; hash in the
106-
// compiler's internal def-path, guaranteeing each symbol has a
107-
// truly unique path
108-
tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
109-
110-
// Include the main item-type. Note that, in this case, the
111-
// assertions about `has_param` may not hold, but this item-type
112-
// ought to be the same for every reference anyway.
113-
assert!(!item_type.has_erasable_regions());
114-
hcx.while_hashing_spans(false, |hcx| {
115-
item_type.hash_stable(hcx, &mut hasher);
116-
117-
// If this is a function, we hash the signature as well.
118-
// This is not *strictly* needed, but it may help in some
119-
// situations, see the `run-make/a-b-a-linker-guard` test.
120-
if let ty::FnDef(..) = item_type.kind() {
121-
item_type.fn_sig(tcx).hash_stable(hcx, &mut hasher);
122-
}
103+
// the main symbol name is not necessarily unique; hash in the
104+
// compiler's internal def-path, guaranteeing each symbol has a
105+
// truly unique path
106+
tcx.def_path_hash(def_id).hash_stable(&mut hcx, &mut hasher);
107+
108+
// Include the main item-type. Note that, in this case, the
109+
// assertions about `has_param` may not hold, but this item-type
110+
// ought to be the same for every reference anyway.
111+
assert!(!item_type.has_erasable_regions());
112+
hcx.while_hashing_spans(false, |hcx| {
113+
item_type.hash_stable(hcx, &mut hasher);
114+
115+
// If this is a function, we hash the signature as well.
116+
// This is not *strictly* needed, but it may help in some
117+
// situations, see the `run-make/a-b-a-linker-guard` test.
118+
if let ty::FnDef(..) = item_type.kind() {
119+
item_type.fn_sig(tcx).hash_stable(hcx, &mut hasher);
120+
}
123121

124-
// also include any type parameters (for generic items)
125-
args.hash_stable(hcx, &mut hasher);
122+
// also include any type parameters (for generic items)
123+
args.hash_stable(hcx, &mut hasher);
126124

127-
if let Some(instantiating_crate) = instantiating_crate {
128-
tcx.def_path_hash(instantiating_crate.as_def_id())
129-
.stable_crate_id()
130-
.hash_stable(hcx, &mut hasher);
131-
}
125+
if let Some(instantiating_crate) = instantiating_crate {
126+
tcx.def_path_hash(instantiating_crate.as_def_id())
127+
.stable_crate_id()
128+
.hash_stable(hcx, &mut hasher);
129+
}
132130

133-
// We want to avoid accidental collision between different types of instances.
134-
// Especially, `VTableShim`s and `ReifyShim`s may overlap with their original
135-
// instances without this.
136-
discriminant(&instance.def).hash_stable(hcx, &mut hasher);
137-
});
131+
// We want to avoid accidental collision between different types of instances.
132+
// Especially, `VTableShim`s and `ReifyShim`s may overlap with their original
133+
// instances without this.
134+
discriminant(&instance.def).hash_stable(hcx, &mut hasher);
138135
});
139136

140137
// 64 bits should be enough to avoid collisions.

compiler/rustc_traits/src/normalize_erasing_regions.rs

-6
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@ use rustc_middle::traits::query::NoSolution;
44
use rustc_middle::ty::{self, ParamEnvAnd, TyCtxt, TypeFoldable, TypeVisitableExt};
55
use rustc_trait_selection::traits::query::normalize::QueryNormalizeExt;
66
use rustc_trait_selection::traits::{Normalized, ObligationCause};
7-
use std::sync::atomic::Ordering;
87

98
pub(crate) fn provide(p: &mut Providers) {
109
*p = Providers {
1110
try_normalize_generic_arg_after_erasing_regions: |tcx, goal| {
1211
debug!("try_normalize_generic_arg_after_erasing_regions(goal={:#?}", goal);
1312

14-
tcx.sess
15-
.perf_stats
16-
.normalize_generic_arg_after_erasing_regions
17-
.fetch_add(1, Ordering::Relaxed);
18-
1913
try_normalize_after_erasing_regions(tcx, goal)
2014
},
2115
..*p

compiler/rustc_traits/src/normalize_projection_ty.rs

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use rustc_trait_selection::traits::query::{
1010
use rustc_trait_selection::traits::{
1111
self, FulfillmentErrorCode, ObligationCause, SelectionContext,
1212
};
13-
use std::sync::atomic::Ordering;
1413

1514
pub(crate) fn provide(p: &mut Providers) {
1615
*p = Providers {
@@ -27,7 +26,6 @@ fn normalize_projection_ty<'tcx>(
2726
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> {
2827
debug!("normalize_provider(goal={:#?})", goal);
2928

30-
tcx.sess.perf_stats.normalize_projection_ty.fetch_add(1, Ordering::Relaxed);
3129
tcx.infer_ctxt().enter_canonical_trait_query(
3230
&goal,
3331
|ocx, ParamEnvAnd { param_env, value: goal }| {
@@ -78,7 +76,6 @@ fn normalize_weak_ty<'tcx>(
7876
) -> Result<&'tcx Canonical<'tcx, QueryResponse<'tcx, NormalizationResult<'tcx>>>, NoSolution> {
7977
debug!("normalize_provider(goal={:#?})", goal);
8078

81-
tcx.sess.perf_stats.normalize_projection_ty.fetch_add(1, Ordering::Relaxed);
8279
tcx.infer_ctxt().enter_canonical_trait_query(
8380
&goal,
8481
|ocx, ParamEnvAnd { param_env, value: goal }| {

0 commit comments

Comments
 (0)