Skip to content

Commit c16b39c

Browse files
committed
analysis_stats: Record lang item queries, disable async drop in stats
1 parent 9e833ab commit c16b39c

File tree

7 files changed

+34
-9
lines changed

7 files changed

+34
-9
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616
CI: 1
1717
RUST_BACKTRACE: short
1818
RUSTUP_MAX_RETRIES: 10
19+
RUSTFLAGS: "-D warnings -W unreachable-pub --cfg no_salsa_async_drops"
1920

2021
defaults:
2122
run:
@@ -41,8 +42,6 @@ jobs:
4142
if: github.repository == 'rust-lang/rust-analyzer'
4243
name: proc-macro-srv
4344
runs-on: ubuntu-latest
44-
env:
45-
RUSTFLAGS: "-D warnings"
4645

4746
steps:
4847
- name: Checkout repository
@@ -80,7 +79,6 @@ jobs:
8079
name: Rust
8180
runs-on: ${{ matrix.os }}
8281
env:
83-
RUSTFLAGS: "-Dwarnings"
8482
CC: deny_c
8583

8684
strategy:
@@ -207,8 +205,6 @@ jobs:
207205
# crate should
208206
- target: wasm32-unknown-unknown
209207
ide-only: true
210-
env:
211-
RUSTFLAGS: "-Dwarnings"
212208

213209
steps:
214210
- name: Checkout repository

.github/workflows/metrics.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
env:
88
CARGO_INCREMENTAL: 0
99
CARGO_NET_RETRY: 10
10-
RUSTFLAGS: "-D warnings -W unreachable-pub"
10+
RUSTFLAGS: "-D warnings -W unreachable-pub -cfg no_salsa_async_drops"
1111
RUSTUP_MAX_RETRIES: 10
1212

1313
jobs:

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ hashbrown = { version = "0.14.*", features = [
184184
elided_lifetimes_in_paths = "warn"
185185
explicit_outlives_requirements = "warn"
186186
unsafe_op_in_unsafe_fn = "warn"
187-
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)'] }
187+
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bootstrap)', "cfg(no_salsa_async_drops)"] }
188188
unused_extern_crates = "warn"
189189
unused_lifetimes = "warn"
190190
unreachable_pub = "warn"

crates/rust-analyzer/src/cli/analysis_stats.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::{
1111
use cfg::{CfgAtom, CfgDiff};
1212
use hir::{
1313
Adt, AssocItem, Crate, DefWithBody, FindPathConfig, HasCrate, HasSource, HirDisplay, ModuleDef,
14-
Name,
14+
Name, crate_lang_items,
1515
db::{DefDatabase, ExpandDatabase, HirDatabase},
1616
next_solver::{DbInterner, GenericArgs},
1717
};
@@ -200,7 +200,7 @@ impl flags::AnalysisStats {
200200
let mut num_crates = 0;
201201
let mut visited_modules = FxHashSet::default();
202202
let mut visit_queue = Vec::new();
203-
for krate in krates {
203+
for &krate in &krates {
204204
let module = krate.root_module();
205205
let file_id = module.definition_source_file_id(db);
206206
let file_id = file_id.original_file(db);
@@ -313,6 +313,10 @@ impl flags::AnalysisStats {
313313
}
314314

315315
hir::attach_db(db, || {
316+
if !self.skip_lang_items {
317+
self.run_lang_items(db, &krates, verbosity);
318+
}
319+
316320
if !self.skip_lowering {
317321
self.run_body_lowering(db, &vfs, &bodies, verbosity);
318322
}
@@ -1109,6 +1113,26 @@ impl flags::AnalysisStats {
11091113
report_metric("body lowering time", body_lowering_time.time.as_millis() as u64, "ms");
11101114
}
11111115

1116+
fn run_lang_items(&self, db: &RootDatabase, crates: &[Crate], verbosity: Verbosity) {
1117+
let mut bar = match verbosity {
1118+
Verbosity::Quiet | Verbosity::Spammy => ProgressReport::hidden(),
1119+
_ if self.output.is_some() => ProgressReport::hidden(),
1120+
_ => ProgressReport::new(crates.len()),
1121+
};
1122+
1123+
let mut sw = self.stop_watch();
1124+
bar.tick();
1125+
for &krate in crates {
1126+
crate_lang_items(db, krate.into());
1127+
bar.inc(1);
1128+
}
1129+
1130+
bar.finish_and_clear();
1131+
let time = sw.elapsed();
1132+
eprintln!("{:<20} {}", "Crate lang items:", time);
1133+
report_metric("crate lang items time", time.time.as_millis() as u64, "ms");
1134+
}
1135+
11121136
/// Invariant: `file_ids` must be sorted and deduped before passing into here
11131137
fn run_ide_things(
11141138
&self,

crates/rust-analyzer/src/cli/flags.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ xflags::xflags! {
7878
optional --disable-proc-macros
7979
/// Run the proc-macro-srv binary at the specified path.
8080
optional --proc-macro-srv path: PathBuf
81+
/// Skip lang items fetching.
82+
optional --skip-lang-items
8183
/// Skip body lowering.
8284
optional --skip-lowering
8385
/// Skip type inference.
@@ -256,6 +258,7 @@ pub struct AnalysisStats {
256258
pub disable_proc_macros: bool,
257259
pub proc_macro_srv: Option<PathBuf>,
258260
pub skip_lowering: bool,
261+
pub skip_lang_items: bool,
259262
pub skip_inference: bool,
260263
pub skip_mir_stats: bool,
261264
pub skip_data_layout: bool,

crates/span/src/map.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ where
156156
}
157157
}
158158

159+
#[cfg(not(no_salsa_async_drops))]
159160
impl<S> Drop for SpanMap<S> {
160161
fn drop(&mut self) {
161162
struct SendPtr(*mut [()]);

crates/syntax/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ impl ast::Expr {
200200
}
201201
}
202202

203+
#[cfg(not(no_salsa_async_drops))]
203204
impl<T> Drop for Parse<T> {
204205
fn drop(&mut self) {
205206
let Some(green) = self.green.take() else {

0 commit comments

Comments
 (0)