Skip to content

Commit 42983a2

Browse files
committed
Auto merge of #90067 - JohnTitor:rollup-afrjulz, r=JohnTitor
Rollup of 10 pull requests Successful merges: - #86479 (Automatic exponential formatting in Debug) - #87404 (Add support for artifact size profiling) - #87769 (Alloc features cleanup) - #88789 (remove unnecessary bound on Zip specialization impl) - #88860 (Deduplicate panic_fmt) - #90009 (Make more `From` impls `const` (libcore)) - #90018 (Fix rustdoc UI for very long type names) - #90025 (Revert #86011 to fix an incorrect bound check) - #90036 (Remove border-bottom from most docblocks.) - #90060 (Update RELEASES.md) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1af55d1 + e54ebe9 commit 42983a2

File tree

82 files changed

+637
-367
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+637
-367
lines changed

Diff for: Cargo.lock

+19-5
Original file line numberDiff line numberDiff line change
@@ -2143,6 +2143,20 @@ dependencies = [
21432143
"smallvec",
21442144
]
21452145

2146+
[[package]]
2147+
name = "measureme"
2148+
version = "10.0.0"
2149+
source = "registry+https://github.com/rust-lang/crates.io-index"
2150+
checksum = "bd460fad6e55ca82fa0cd9dab0d315294188fd9ec6efbf4105e5635d4872ef9c"
2151+
dependencies = [
2152+
"log",
2153+
"memmap2",
2154+
"parking_lot",
2155+
"perf-event-open-sys",
2156+
"rustc-hash",
2157+
"smallvec",
2158+
]
2159+
21462160
[[package]]
21472161
name = "memchr"
21482162
version = "2.4.1"
@@ -2247,7 +2261,7 @@ dependencies = [
22472261
"hex 0.4.2",
22482262
"libc",
22492263
"log",
2250-
"measureme",
2264+
"measureme 9.1.2",
22512265
"rand 0.8.4",
22522266
"rustc-workspace-hack",
22532267
"rustc_version 0.4.0",
@@ -3235,7 +3249,7 @@ dependencies = [
32353249
"indexmap",
32363250
"jobserver",
32373251
"libc",
3238-
"measureme",
3252+
"measureme 9.1.2",
32393253
"memmap2",
32403254
"parking_lot",
32413255
"rustc-ap-rustc_graphviz",
@@ -3674,7 +3688,7 @@ dependencies = [
36743688
"bitflags",
36753689
"cstr",
36763690
"libc",
3677-
"measureme",
3691+
"measureme 10.0.0",
36783692
"rustc-demangle",
36793693
"rustc_arena",
36803694
"rustc_ast",
@@ -3767,7 +3781,7 @@ dependencies = [
37673781
"indexmap",
37683782
"jobserver",
37693783
"libc",
3770-
"measureme",
3784+
"measureme 10.0.0",
37713785
"memmap2",
37723786
"parking_lot",
37733787
"rustc-hash",
@@ -4292,7 +4306,7 @@ dependencies = [
42924306
name = "rustc_query_impl"
42934307
version = "0.0.0"
42944308
dependencies = [
4295-
"measureme",
4309+
"measureme 10.0.0",
42964310
"rustc-rayon-core",
42974311
"rustc_ast",
42984312
"rustc_data_structures",

Diff for: RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Cargo
7777
- [Cargo supports specifying a minimum supported Rust version in Cargo.toml.][`rust-version`]
7878
This has no effect at present on dependency version selection.
7979
We encourage crates to specify their minimum supported Rust version, and we encourage CI systems
80-
that support Rust code to include a crate's specified minimum version in the text matrix for that
80+
that support Rust code to include a crate's specified minimum version in the test matrix for that
8181
crate by default.
8282

8383
Compatibility notes

Diff for: compiler/rustc_codegen_llvm/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ doctest = false
1111
bitflags = "1.0"
1212
cstr = "0.2"
1313
libc = "0.2"
14-
measureme = "9.1.0"
14+
measureme = "10.0.0"
1515
snap = "1"
1616
tracing = "0.1"
1717
rustc_middle = { path = "../rustc_middle" }

Diff for: compiler/rustc_const_eval/src/const_eval/machine.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@ impl<'mir, 'tcx> InterpCx<'mir, 'tcx, CompileTimeInterpreter<'mir, 'tcx>> {
7272
let span = self.find_closest_untracked_caller_location();
7373
let (file, line, col) = self.location_triple_for_span(span);
7474
return Err(ConstEvalErrKind::Panic { msg, file, line, col }.into());
75-
} else if Some(def_id) == self.tcx.lang_items().panic_fmt()
76-
|| Some(def_id) == self.tcx.lang_items().begin_panic_fmt()
77-
{
75+
} else if Some(def_id) == self.tcx.lang_items().panic_fmt() {
7876
// For panic_fmt, call const_panic_fmt instead.
7977
if let Some(const_panic_fmt) = self.tcx.lang_items().const_panic_fmt() {
8078
return Ok(Some(

Diff for: compiler/rustc_const_eval/src/transform/check_consts/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ pub fn is_lang_panic_fn(tcx: TyCtxt<'tcx>, def_id: DefId) -> bool {
7979
|| Some(def_id) == tcx.lang_items().panic_display()
8080
|| Some(def_id) == tcx.lang_items().begin_panic_fn()
8181
|| Some(def_id) == tcx.lang_items().panic_fmt()
82-
|| Some(def_id) == tcx.lang_items().begin_panic_fmt()
8382
}
8483

8584
/// Returns `true` if this `DefId` points to one of the lang items that will be handled differently

Diff for: compiler/rustc_data_structures/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ rustc-hash = "1.1.0"
2323
smallvec = { version = "1.6.1", features = ["union", "may_dangle"] }
2424
rustc_index = { path = "../rustc_index", package = "rustc_index" }
2525
bitflags = "1.2.1"
26-
measureme = "9.1.0"
26+
measureme = "10.0.0"
2727
libc = "0.2"
2828
stacker = "0.1.14"
2929
tempfile = "3.2"

Diff for: compiler/rustc_data_structures/src/profiling.rs

+40-3
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ bitflags::bitflags! {
110110
const FUNCTION_ARGS = 1 << 6;
111111
const LLVM = 1 << 7;
112112
const INCR_RESULT_HASHING = 1 << 8;
113+
const ARTIFACT_SIZES = 1 << 9;
113114

114115
const DEFAULT = Self::GENERIC_ACTIVITIES.bits |
115116
Self::QUERY_PROVIDERS.bits |
116117
Self::QUERY_BLOCKED.bits |
117118
Self::INCR_CACHE_LOADS.bits |
118-
Self::INCR_RESULT_HASHING.bits;
119+
Self::INCR_RESULT_HASHING.bits |
120+
Self::ARTIFACT_SIZES.bits;
119121

120122
const ARGS = Self::QUERY_KEYS.bits | Self::FUNCTION_ARGS.bits;
121123
}
@@ -136,6 +138,7 @@ const EVENT_FILTERS_BY_NAME: &[(&str, EventFilter)] = &[
136138
("args", EventFilter::ARGS),
137139
("llvm", EventFilter::LLVM),
138140
("incr-result-hashing", EventFilter::INCR_RESULT_HASHING),
141+
("artifact-sizes", EventFilter::ARTIFACT_SIZES),
139142
];
140143

141144
/// Something that uniquely identifies a query invocation.
@@ -285,6 +288,33 @@ impl SelfProfilerRef {
285288
})
286289
}
287290

291+
/// Record the size of an artifact that the compiler produces
292+
///
293+
/// `artifact_kind` is the class of artifact (e.g., query_cache, object_file, etc.)
294+
/// `artifact_name` is an identifier to the specific artifact being stored (usually a filename)
295+
#[inline(always)]
296+
pub fn artifact_size<A>(&self, artifact_kind: &str, artifact_name: A, size: u64)
297+
where
298+
A: Borrow<str> + Into<String>,
299+
{
300+
drop(self.exec(EventFilter::ARTIFACT_SIZES, |profiler| {
301+
let builder = EventIdBuilder::new(&profiler.profiler);
302+
let event_label = profiler.get_or_alloc_cached_string(artifact_kind);
303+
let event_arg = profiler.get_or_alloc_cached_string(artifact_name);
304+
let event_id = builder.from_label_and_arg(event_label, event_arg);
305+
let thread_id = get_thread_id();
306+
307+
profiler.profiler.record_integer_event(
308+
profiler.artifact_size_event_kind,
309+
event_id,
310+
thread_id,
311+
size,
312+
);
313+
314+
TimingGuard::none()
315+
}))
316+
}
317+
288318
#[inline(always)]
289319
pub fn generic_activity_with_args(
290320
&self,
@@ -372,7 +402,7 @@ impl SelfProfilerRef {
372402
) {
373403
drop(self.exec(event_filter, |profiler| {
374404
let event_id = StringId::new_virtual(query_invocation_id.0);
375-
let thread_id = std::thread::current().id().as_u64().get() as u32;
405+
let thread_id = get_thread_id();
376406

377407
profiler.profiler.record_instant_event(
378408
event_kind(profiler),
@@ -425,6 +455,7 @@ pub struct SelfProfiler {
425455
incremental_result_hashing_event_kind: StringId,
426456
query_blocked_event_kind: StringId,
427457
query_cache_hit_event_kind: StringId,
458+
artifact_size_event_kind: StringId,
428459
}
429460

430461
impl SelfProfiler {
@@ -447,6 +478,7 @@ impl SelfProfiler {
447478
profiler.alloc_string("IncrementalResultHashing");
448479
let query_blocked_event_kind = profiler.alloc_string("QueryBlocked");
449480
let query_cache_hit_event_kind = profiler.alloc_string("QueryCacheHit");
481+
let artifact_size_event_kind = profiler.alloc_string("ArtifactSize");
450482

451483
let mut event_filter_mask = EventFilter::empty();
452484

@@ -491,6 +523,7 @@ impl SelfProfiler {
491523
incremental_result_hashing_event_kind,
492524
query_blocked_event_kind,
493525
query_cache_hit_event_kind,
526+
artifact_size_event_kind,
494527
})
495528
}
496529

@@ -561,7 +594,7 @@ impl<'a> TimingGuard<'a> {
561594
event_kind: StringId,
562595
event_id: EventId,
563596
) -> TimingGuard<'a> {
564-
let thread_id = std::thread::current().id().as_u64().get() as u32;
597+
let thread_id = get_thread_id();
565598
let raw_profiler = &profiler.profiler;
566599
let timing_guard =
567600
raw_profiler.start_recording_interval_event(event_kind, event_id, thread_id);
@@ -655,6 +688,10 @@ pub fn duration_to_secs_str(dur: std::time::Duration) -> String {
655688
format!("{:.3}", dur.as_secs_f64())
656689
}
657690

691+
fn get_thread_id() -> u32 {
692+
std::thread::current().id().as_u64().get() as u32
693+
}
694+
658695
// Memory reporting
659696
cfg_if! {
660697
if #[cfg(windows)] {

Diff for: compiler/rustc_hir/src/lang_items.rs

-1
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,6 @@ language_item_table! {
292292
PanicImpl, sym::panic_impl, panic_impl, Target::Fn, GenericRequirement::None;
293293
/// libstd panic entry point. Necessary for const eval to be able to catch it
294294
BeginPanic, sym::begin_panic, begin_panic_fn, Target::Fn, GenericRequirement::None;
295-
BeginPanicFmt, sym::begin_panic_fmt, begin_panic_fmt, Target::Fn, GenericRequirement::None;
296295

297296
ExchangeMalloc, sym::exchange_malloc, exchange_malloc_fn, Target::Fn, GenericRequirement::None;
298297
BoxFree, sym::box_free, box_free_fn, Target::Fn, GenericRequirement::Minimum(1);

Diff for: compiler/rustc_incremental/src/persist/file_format.rs

+6
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ where
9595
return;
9696
}
9797

98+
sess.prof.artifact_size(
99+
&name.replace(' ', "_"),
100+
path_buf.file_name().unwrap().to_string_lossy(),
101+
encoder.position() as u64,
102+
);
103+
98104
debug!("save: data written to disk successfully");
99105
}
100106

Diff for: compiler/rustc_query_impl/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77
doctest = false
88

99
[dependencies]
10-
measureme = "9.0.0"
10+
measureme = "10.0.0"
1111
rustc-rayon-core = "0.3.1"
1212
tracing = "0.1"
1313
rustc_ast = { path = "../rustc_ast" }

Diff for: compiler/rustc_query_system/src/dep_graph/serialized.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ impl<K: DepKind> EncoderState<K> {
222222
index
223223
}
224224

225-
fn finish(self) -> FileEncodeResult {
225+
fn finish(self, profiler: &SelfProfilerRef) -> FileEncodeResult {
226226
let Self { mut encoder, total_node_count, total_edge_count, result, stats: _ } = self;
227227
let () = result?;
228228

@@ -235,7 +235,11 @@ impl<K: DepKind> EncoderState<K> {
235235
IntEncodedWithFixedSize(edge_count).encode(&mut encoder)?;
236236
debug!("position: {:?}", encoder.position());
237237
// Drop the encoder so that nothing is written after the counts.
238-
encoder.flush()
238+
let result = encoder.flush();
239+
// FIXME(rylev): we hardcode the dep graph file name so we don't need a dependency on
240+
// rustc_incremental just for that.
241+
profiler.artifact_size("dep_graph", "dep-graph.bin", encoder.position() as u64);
242+
result
239243
}
240244
}
241245

@@ -332,6 +336,6 @@ impl<K: DepKind + Encodable<FileEncoder>> GraphEncoder<K> {
332336

333337
pub fn finish(self, profiler: &SelfProfilerRef) -> FileEncodeResult {
334338
let _prof_timer = profiler.generic_activity("incr_comp_encode_dep_graph");
335-
self.status.into_inner().finish()
339+
self.status.into_inner().finish(profiler)
336340
}
337341
}

Diff for: compiler/rustc_session/src/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1283,7 +1283,7 @@ options! {
12831283
"specify the events recorded by the self profiler;
12841284
for example: `-Z self-profile-events=default,query-keys`
12851285
all options: none, all, default, generic-activity, query-provider, query-cache-hit
1286-
query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm"),
1286+
query-blocked, incr-cache-load, incr-result-hashing, query-keys, function-args, args, llvm, artifact-sizes"),
12871287
share_generics: Option<bool> = (None, parse_opt_bool, [TRACKED],
12881288
"make the current crate share its generic instantiations"),
12891289
show_span: Option<String> = (None, parse_opt_string, [TRACKED],

Diff for: compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ symbols! {
355355
await_macro,
356356
bang,
357357
begin_panic,
358-
begin_panic_fmt,
359358
bench,
360359
bin,
361360
bind_by_move_pattern_guards,

Diff for: compiler/rustc_typeck/src/bounds.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ impl<'tcx> Bounds<'tcx> {
6464
})
6565
});
6666

67-
self.region_bounds
68-
.iter()
69-
.map(|&(region_bound, span)| {
67+
sized_predicate
68+
.into_iter()
69+
.chain(self.region_bounds.iter().map(|&(region_bound, span)| {
7070
(
7171
region_bound
7272
.map_bound(|region_bound| ty::OutlivesPredicate(param_ty, region_bound))
7373
.to_predicate(tcx),
7474
span,
7575
)
76-
})
76+
}))
7777
.chain(self.trait_bounds.iter().map(|&(bound_trait_ref, span, constness)| {
7878
let predicate = bound_trait_ref.with_constness(constness).to_predicate(tcx);
7979
(predicate, span)
@@ -83,7 +83,6 @@ impl<'tcx> Bounds<'tcx> {
8383
.iter()
8484
.map(|&(projection, span)| (projection.to_predicate(tcx), span)),
8585
)
86-
.chain(sized_predicate.into_iter())
8786
.collect()
8887
}
8988
}

0 commit comments

Comments
 (0)