Skip to content

Commit 3227369

Browse files
committed
Auto merge of rust-lang#118496 - SparrowLii:parallel_3, r=<try>
perf test for removing some parallelism in `encode_metadata` perf test for rust-lang#118488
2 parents a1c65db + 1880cdb commit 3227369

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

compiler/rustc_metadata/src/rmeta/encoder.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -2193,21 +2193,13 @@ pub fn encode_metadata(tcx: TyCtxt<'_>, path: &Path) {
21932193
// there's no need to do dep-graph tracking for any of it.
21942194
tcx.dep_graph.assert_ignored();
21952195

2196-
join(
2197-
|| encode_metadata_impl(tcx, path),
2198-
|| {
2199-
if tcx.sess.threads() == 1 {
2200-
return;
2201-
}
2202-
// Prefetch some queries used by metadata encoding.
2203-
// This is not necessary for correctness, but is only done for performance reasons.
2204-
// It can be removed if it turns out to cause trouble or be detrimental to performance.
2205-
join(|| prefetch_mir(tcx), || tcx.exported_symbols(LOCAL_CRATE));
2206-
},
2207-
);
2208-
}
2209-
2210-
fn encode_metadata_impl(tcx: TyCtxt<'_>, path: &Path) {
2196+
if tcx.sess.threads() != 1 {
2197+
// Prefetch some queries used by metadata encoding.
2198+
// This is not necessary for correctness, but is only done for performance reasons.
2199+
// It can be removed if it turns out to cause trouble or be detrimental to performance.
2200+
join(|| prefetch_mir(tcx), || tcx.exported_symbols(LOCAL_CRATE));
2201+
}
2202+
22112203
let mut encoder = opaque::FileEncoder::new(path)
22122204
.unwrap_or_else(|err| tcx.sess.emit_fatal(FailCreateFileEncoder { err }));
22132205
encoder.emit_raw_bytes(METADATA_HEADER);

compiler/rustc_session/src/options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,7 @@ written to standard error output)"),
18971897
/// in the future. Note that -Zthreads=0 is the way to get
18981898
/// the num_cpus behavior.
18991899
#[rustc_lint_opt_deny_field_access("use `Session::threads` instead of this field")]
1900-
threads: usize = (1, parse_threads, [UNTRACKED],
1900+
threads: usize = (8, parse_threads, [UNTRACKED],
19011901
"use a thread pool with N threads"),
19021902
time_llvm_passes: bool = (false, parse_bool, [UNTRACKED],
19031903
"measure time of each LLVM pass (default: no)"),

0 commit comments

Comments
 (0)