Skip to content

Commit e85089b

Browse files
Remove -Zprofile-queries
1 parent 032a53a commit e85089b

File tree

14 files changed

+11
-771
lines changed

14 files changed

+11
-771
lines changed

src/librustc/dep_graph/graph.rs

-9
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ use std::hash::Hash;
99
use std::collections::hash_map::Entry;
1010
use std::mem;
1111
use crate::ty::{self, TyCtxt};
12-
use crate::util::common::{ProfileQueriesMsg, profq_msg};
1312
use parking_lot::{Mutex, Condvar};
1413

1514
use crate::ich::{StableHashingContext, StableHashingContextProvider, Fingerprint};
@@ -260,10 +259,6 @@ impl DepGraph {
260259
// - we can get an idea of the runtime cost.
261260
let mut hcx = cx.get_stable_hashing_context();
262261

263-
if cfg!(debug_assertions) {
264-
profq_msg(hcx.sess(), ProfileQueriesMsg::TaskBegin(key.clone()))
265-
};
266-
267262
let result = if no_tcx {
268263
task(cx, arg)
269264
} else {
@@ -279,10 +274,6 @@ impl DepGraph {
279274
})
280275
};
281276

282-
if cfg!(debug_assertions) {
283-
profq_msg(hcx.sess(), ProfileQueriesMsg::TaskEnd)
284-
};
285-
286277
let current_fingerprint = hash_result(&mut hcx, &result);
287278

288279
let dep_node_index = finish_task_and_alloc_depnode(

src/librustc/session/config.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1316,10 +1316,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
13161316
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
13171317
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],
13181318
"enable queries of the dependency graph for regression testing"),
1319-
profile_queries: bool = (false, parse_bool, [UNTRACKED],
1320-
"trace and profile the queries of the incremental compilation framework"),
1321-
profile_queries_and_keys: bool = (false, parse_bool, [UNTRACKED],
1322-
"trace and profile the queries and keys of the incremental compilation framework"),
13231319
no_analysis: bool = (false, parse_bool, [UNTRACKED],
13241320
"parse and expand the source, but run no analysis"),
13251321
extra_plugins: Vec<String> = (Vec::new(), parse_list, [TRACKED],

src/librustc/session/mod.rs

+1-13
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::session::config::{OutputType, PrintRequest, SwitchWithOptPath};
1111
use crate::session::search_paths::{PathKind, SearchPath};
1212
use crate::util::nodemap::{FxHashMap, FxHashSet};
1313
use crate::util::common::{duration_to_secs_str, ErrorReported};
14-
use crate::util::common::ProfileQueriesMsg;
1514

1615
use rustc_data_structures::base_n;
1716
use rustc_data_structures::sync::{
@@ -46,7 +45,7 @@ use std::fmt;
4645
use std::io::Write;
4746
use std::path::PathBuf;
4847
use std::time::Duration;
49-
use std::sync::{Arc, mpsc};
48+
use std::sync::Arc;
5049

5150
mod code_stats;
5251
pub mod config;
@@ -125,9 +124,6 @@ pub struct Session {
125124
/// `-Zquery-dep-graph` is specified.
126125
pub cgu_reuse_tracker: CguReuseTracker,
127126

128-
/// Used by `-Z profile-queries` in `util::common`.
129-
pub profile_channel: Lock<Option<mpsc::Sender<ProfileQueriesMsg>>>,
130-
131127
/// Used by `-Z self-profile`.
132128
pub prof: SelfProfilerRef,
133129

@@ -509,13 +505,6 @@ impl Session {
509505
pub fn time_extended(&self) -> bool {
510506
self.opts.debugging_opts.time_passes
511507
}
512-
pub fn profile_queries(&self) -> bool {
513-
self.opts.debugging_opts.profile_queries
514-
|| self.opts.debugging_opts.profile_queries_and_keys
515-
}
516-
pub fn profile_queries_and_keys(&self) -> bool {
517-
self.opts.debugging_opts.profile_queries_and_keys
518-
}
519508
pub fn instrument_mcount(&self) -> bool {
520509
self.opts.debugging_opts.instrument_mcount
521510
}
@@ -1234,7 +1223,6 @@ fn build_session_(
12341223
incr_comp_session: OneThread::new(RefCell::new(IncrCompSession::NotInitialized)),
12351224
cgu_reuse_tracker,
12361225
prof: SelfProfilerRef::new(self_profiler),
1237-
profile_channel: Lock::new(None),
12381226
perf_stats: PerfStats {
12391227
symbol_hash_time: Lock::new(Duration::from_secs(0)),
12401228
decode_def_path_tables_time: Lock::new(Duration::from_secs(0)),

src/librustc/ty/query/on_disk_cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ where
10751075
let desc = &format!("encode_query_results for {}",
10761076
::std::any::type_name::<Q>());
10771077

1078-
time_ext(tcx.sess.time_extended(), Some(tcx.sess), desc, || {
1078+
time_ext(tcx.sess.time_extended(), desc, || {
10791079
let shards = Q::query_cache(tcx).lock_shards();
10801080
assert!(shards.iter().all(|shard| shard.active.is_empty()));
10811081
for (key, entry) in shards.iter().flat_map(|shard| shard.results.iter()) {

src/librustc/ty/query/plumbing.rs

-49
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ use crate::ty::query::Query;
99
use crate::ty::query::config::{QueryConfig, QueryDescription};
1010
use crate::ty::query::job::{QueryJob, QueryResult, QueryInfo};
1111

12-
use crate::util::common::{profq_msg, ProfileQueriesMsg, QueryMsg};
13-
1412
use errors::DiagnosticBuilder;
1513
use errors::Level;
1614
use errors::Diagnostic;
@@ -62,33 +60,6 @@ impl<'tcx, M: QueryConfig<'tcx>> Default for QueryCache<'tcx, M> {
6260
}
6361
}
6462

65-
// If enabled, sends a message to the profile-queries thread.
66-
macro_rules! profq_msg {
67-
($tcx:expr, $msg:expr) => {
68-
if cfg!(debug_assertions) {
69-
if $tcx.sess.profile_queries() {
70-
profq_msg($tcx.sess, $msg)
71-
}
72-
}
73-
}
74-
}
75-
76-
// If enabled, formats a key using its debug string, which can be
77-
// expensive to compute (in terms of time).
78-
macro_rules! profq_query_msg {
79-
($query:expr, $tcx:expr, $key:expr) => {{
80-
let msg = if cfg!(debug_assertions) {
81-
if $tcx.sess.profile_queries_and_keys() {
82-
Some(format!("{:?}", $key))
83-
} else { None }
84-
} else { None };
85-
QueryMsg {
86-
query: $query,
87-
msg,
88-
}
89-
}}
90-
}
91-
9263
/// A type representing the responsibility to execute the job in the `job` field.
9364
/// This will poison the relevant query if dropped.
9465
pub(super) struct JobOwner<'a, 'tcx, Q: QueryDescription<'tcx>> {
@@ -111,7 +82,6 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
11182
loop {
11283
let mut lock = cache.get_shard_by_value(key).lock();
11384
if let Some(value) = lock.results.get(key) {
114-
profq_msg!(tcx, ProfileQueriesMsg::CacheHit);
11585
tcx.prof.query_cache_hit(Q::NAME);
11686
let result = (value.value.clone(), value.index);
11787
#[cfg(debug_assertions)]
@@ -358,13 +328,6 @@ impl<'tcx> TyCtxt<'tcx> {
358328
key,
359329
span);
360330

361-
profq_msg!(self,
362-
ProfileQueriesMsg::QueryBegin(
363-
span.data(),
364-
profq_query_msg!(Q::NAME.as_str(), self, key),
365-
)
366-
);
367-
368331
let job = match JobOwner::try_get(self, span, &key) {
369332
TryGetJob::NotYetStarted(job) => job,
370333
TryGetJob::Cycle(result) => return result,
@@ -383,7 +346,6 @@ impl<'tcx> TyCtxt<'tcx> {
383346

384347
if Q::ANON {
385348

386-
profq_msg!(self, ProfileQueriesMsg::ProviderBegin);
387349
let prof_timer = self.prof.query_provider(Q::NAME);
388350

389351
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
@@ -395,7 +357,6 @@ impl<'tcx> TyCtxt<'tcx> {
395357
});
396358

397359
drop(prof_timer);
398-
profq_msg!(self, ProfileQueriesMsg::ProviderEnd);
399360

400361
self.dep_graph.read_index(dep_node_index);
401362

@@ -468,7 +429,6 @@ impl<'tcx> TyCtxt<'tcx> {
468429
};
469430

470431
let result = if let Some(result) = result {
471-
profq_msg!(self, ProfileQueriesMsg::CacheHit);
472432
result
473433
} else {
474434
// We could not load a result from the on-disk cache, so
@@ -546,7 +506,6 @@ impl<'tcx> TyCtxt<'tcx> {
546506
- dep-node: {:?}",
547507
key, dep_node);
548508

549-
profq_msg!(self, ProfileQueriesMsg::ProviderBegin);
550509
let prof_timer = self.prof.query_provider(Q::NAME);
551510

552511
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
@@ -568,7 +527,6 @@ impl<'tcx> TyCtxt<'tcx> {
568527
});
569528

570529
drop(prof_timer);
571-
profq_msg!(self, ProfileQueriesMsg::ProviderEnd);
572530

573531
if unlikely!(self.sess.opts.debugging_opts.query_dep_graph) {
574532
self.dep_graph.mark_loaded_from_cache(dep_node_index, false);
@@ -614,19 +572,12 @@ impl<'tcx> TyCtxt<'tcx> {
614572

615573
let _ = self.get_query::<Q>(DUMMY_SP, key);
616574
} else {
617-
profq_msg!(self, ProfileQueriesMsg::CacheHit);
618575
self.prof.query_cache_hit(Q::NAME);
619576
}
620577
}
621578

622579
#[allow(dead_code)]
623580
fn force_query<Q: QueryDescription<'tcx>>(self, key: Q::Key, span: Span, dep_node: DepNode) {
624-
profq_msg!(
625-
self,
626-
ProfileQueriesMsg::QueryBegin(span.data(),
627-
profq_query_msg!(Q::NAME.as_str(), self, key))
628-
);
629-
630581
// We may be concurrently trying both execute and force a query.
631582
// Ensure that only one of them runs the query.
632583
let job = match JobOwner::try_get(self, span, &key) {

src/librustc/util/common.rs

+2-73
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,8 @@ use std::cell::Cell;
66
use std::fmt::Debug;
77
use std::time::{Duration, Instant};
88

9-
use std::sync::mpsc::{Sender};
10-
use syntax_pos::{SpanData};
119
use syntax::symbol::{Symbol, sym};
1210
use rustc_macros::HashStable;
13-
use crate::dep_graph::{DepNode};
1411
use crate::session::Session;
1512

1613
#[cfg(test)]
@@ -26,71 +23,13 @@ pub struct ErrorReported;
2623

2724
thread_local!(static TIME_DEPTH: Cell<usize> = Cell::new(0));
2825

29-
/// Parameters to the `Dump` variant of type `ProfileQueriesMsg`.
30-
#[derive(Clone,Debug)]
31-
pub struct ProfQDumpParams {
32-
/// A base path for the files we will dump.
33-
pub path:String,
34-
/// To ensure that the compiler waits for us to finish our dumps.
35-
pub ack:Sender<()>,
36-
/// Toggle dumping a log file with every `ProfileQueriesMsg`.
37-
pub dump_profq_msg_log:bool,
38-
}
39-
4026
#[allow(nonstandard_style)]
4127
#[derive(Clone, Debug, PartialEq, Eq)]
4228
pub struct QueryMsg {
4329
pub query: &'static str,
4430
pub msg: Option<String>,
4531
}
4632

47-
/// A sequence of these messages induce a trace of query-based incremental compilation.
48-
// FIXME(matthewhammer): Determine whether we should include cycle detection here or not.
49-
#[derive(Clone,Debug)]
50-
pub enum ProfileQueriesMsg {
51-
/// Begin a timed pass.
52-
TimeBegin(String),
53-
/// End a timed pass.
54-
TimeEnd,
55-
/// Begin a task (see `dep_graph::graph::with_task`).
56-
TaskBegin(DepNode),
57-
/// End a task.
58-
TaskEnd,
59-
/// Begin a new query.
60-
/// Cannot use `Span` because queries are sent to other thread.
61-
QueryBegin(SpanData, QueryMsg),
62-
/// Query is satisfied by using an already-known value for the given key.
63-
CacheHit,
64-
/// Query requires running a provider; providers may nest, permitting queries to nest.
65-
ProviderBegin,
66-
/// Query is satisfied by a provider terminating with a value.
67-
ProviderEnd,
68-
/// Dump a record of the queries to the given path.
69-
Dump(ProfQDumpParams),
70-
/// Halt the profiling/monitoring background thread.
71-
Halt
72-
}
73-
74-
/// If enabled, send a message to the profile-queries thread.
75-
pub fn profq_msg(sess: &Session, msg: ProfileQueriesMsg) {
76-
if let Some(s) = sess.profile_channel.borrow().as_ref() {
77-
s.send(msg).unwrap()
78-
} else {
79-
// Do nothing.
80-
}
81-
}
82-
83-
/// Set channel for profile queries channel.
84-
pub fn profq_set_chan(sess: &Session, s: Sender<ProfileQueriesMsg>) -> bool {
85-
let mut channel = sess.profile_channel.borrow_mut();
86-
if channel.is_none() {
87-
*channel = Some(s);
88-
true
89-
} else {
90-
false
91-
}
92-
}
93-
9433
/// Read the current depth of `time()` calls. This is used to
9534
/// encourage indentation across threads.
9635
pub fn time_depth() -> usize {
@@ -107,10 +46,10 @@ pub fn set_time_depth(depth: usize) {
10746
pub fn time<T, F>(sess: &Session, what: &str, f: F) -> T where
10847
F: FnOnce() -> T,
10948
{
110-
time_ext(sess.time_passes(), Some(sess), what, f)
49+
time_ext(sess.time_passes(), what, f)
11150
}
11251

113-
pub fn time_ext<T, F>(do_it: bool, sess: Option<&Session>, what: &str, f: F) -> T where
52+
pub fn time_ext<T, F>(do_it: bool, what: &str, f: F) -> T where
11453
F: FnOnce() -> T,
11554
{
11655
if !do_it { return f(); }
@@ -121,19 +60,9 @@ pub fn time_ext<T, F>(do_it: bool, sess: Option<&Session>, what: &str, f: F) ->
12160
r
12261
});
12362

124-
if let Some(sess) = sess {
125-
if cfg!(debug_assertions) {
126-
profq_msg(sess, ProfileQueriesMsg::TimeBegin(what.to_string()))
127-
}
128-
}
12963
let start = Instant::now();
13064
let rv = f();
13165
let dur = start.elapsed();
132-
if let Some(sess) = sess {
133-
if cfg!(debug_assertions) {
134-
profq_msg(sess, ProfileQueriesMsg::TimeEnd)
135-
}
136-
}
13766

13867
print_time_passes_entry(true, what, dur);
13968

src/librustc_codegen_llvm/back/lto.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn prepare_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
116116
info!("adding bytecode {}", name);
117117
let bc_encoded = data.data();
118118

119-
let (bc, id) = time_ext(cgcx.time_passes, None, &format!("decode {}", name), || {
119+
let (bc, id) = time_ext(cgcx.time_passes, &format!("decode {}", name), || {
120120
match DecodedBytecode::new(bc_encoded) {
121121
Ok(b) => Ok((b.bytecode(), b.identifier().to_string())),
122122
Err(e) => Err(diag_handler.fatal(&e)),
@@ -295,7 +295,7 @@ fn fat_lto(cgcx: &CodegenContext<LlvmCodegenBackend>,
295295
for (bc_decoded, name) in serialized_modules {
296296
let _timer = cgcx.prof.generic_activity("LLVM_fat_lto_link_module");
297297
info!("linking {:?}", name);
298-
time_ext(cgcx.time_passes, None, &format!("ll link {:?}", name), || {
298+
time_ext(cgcx.time_passes, &format!("ll link {:?}", name), || {
299299
let data = bc_decoded.data();
300300
linker.add(&data).map_err(|()| {
301301
let msg = format!("failed to load bc of {:?}", name);
@@ -590,7 +590,7 @@ pub(crate) fn run_pass_manager(cgcx: &CodegenContext<LlvmCodegenBackend>,
590590
llvm::LLVMRustAddPass(pm, pass.unwrap());
591591
}
592592

593-
time_ext(cgcx.time_passes, None, "LTO passes", ||
593+
time_ext(cgcx.time_passes, "LTO passes", ||
594594
llvm::LLVMRunPassManager(pm, module.module_llvm.llmod()));
595595

596596
llvm::LLVMDisposePassManager(pm);

src/librustc_codegen_llvm/back/write.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
427427
{
428428
let _timer = cgcx.prof.generic_activity("LLVM_module_optimize_function_passes");
429429
time_ext(config.time_passes,
430-
None,
431430
&format!("llvm function passes [{}]", module_name.unwrap()),
432431
|| {
433432
llvm::LLVMRustRunFunctionPassManager(fpm, llmod)
@@ -436,7 +435,6 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
436435
{
437436
let _timer = cgcx.prof.generic_activity("LLVM_module_optimize_module_passes");
438437
time_ext(config.time_passes,
439-
None,
440438
&format!("llvm module passes [{}]", module_name.unwrap()),
441439
|| {
442440
llvm::LLVMRunPassManager(mpm, llmod)
@@ -538,7 +536,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<LlvmCodegenBackend>,
538536
embed_bitcode(cgcx, llcx, llmod, None);
539537
}
540538

541-
time_ext(config.time_passes, None, &format!("codegen passes [{}]", module_name.unwrap()),
539+
time_ext(config.time_passes, &format!("codegen passes [{}]", module_name.unwrap()),
542540
|| -> Result<(), FatalError> {
543541
if config.emit_ir {
544542
let _timer = cgcx.prof.generic_activity("LLVM_module_codegen_emit_ir");

0 commit comments

Comments
 (0)