Skip to content

Commit 6cd0dca

Browse files
committed
Prefetch queries used by the metadata encoder
1 parent 3c6f982 commit 6cd0dca

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/librustc_metadata/rmeta/encoder.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_ast::attr;
1818
use rustc_data_structures::fingerprint::Fingerprint;
1919
use rustc_data_structures::fx::FxHashMap;
2020
use rustc_data_structures::stable_hasher::StableHasher;
21-
use rustc_data_structures::sync::Lrc;
21+
use rustc_data_structures::sync::{join, par_for_each_in, Lrc};
2222
use rustc_hir as hir;
2323
use rustc_hir::def::CtorKind;
2424
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
@@ -1721,6 +1721,22 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
17211721
// generated regardless of trailing bytes that end up in it.
17221722

17231723
pub(super) fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
1724+
join(
1725+
|| encode_metadata_impl(tcx),
1726+
|| {
1727+
// Prefetch some queries used by metadata encoding
1728+
tcx.dep_graph.with_ignore(|| {
1729+
par_for_each_in(tcx.mir_keys(LOCAL_CRATE), |&def_id| {
1730+
tcx.optimized_mir(def_id);
1731+
tcx.promoted_mir(def_id);
1732+
});
1733+
})
1734+
},
1735+
)
1736+
.0
1737+
}
1738+
1739+
fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
17241740
let mut encoder = opaque::Encoder::new(vec![]);
17251741
encoder.emit_raw_bytes(METADATA_HEADER);
17261742

0 commit comments

Comments
 (0)