Skip to content

Commit 36cbf0e

Browse files
committed
Prefetch queries used by the metadata encoder
1 parent c010632 commit 36cbf0e

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
@@ -21,7 +21,7 @@ use rustc_index::vec::Idx;
2121
use rustc::session::config::{self, CrateType};
2222
use rustc_data_structures::fx::FxHashMap;
2323
use rustc_data_structures::stable_hasher::StableHasher;
24-
use rustc_data_structures::sync::Lrc;
24+
use rustc_data_structures::sync::{join, par_for_each_in, Lrc};
2525
use rustc_serialize::{opaque, Encodable, Encoder, SpecializedEncoder};
2626

2727
use log::{debug, trace};
@@ -1705,6 +1705,22 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
17051705
// generated regardless of trailing bytes that end up in it.
17061706

17071707
pub(super) fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
1708+
join(
1709+
|| encode_metadata_impl(tcx),
1710+
|| {
1711+
// Prefetch some queries used by metadata encoding
1712+
tcx.dep_graph.with_ignore(|| {
1713+
par_for_each_in(tcx.mir_keys(LOCAL_CRATE), |&def_id| {
1714+
tcx.optimized_mir(def_id);
1715+
tcx.promoted_mir(def_id);
1716+
});
1717+
})
1718+
},
1719+
)
1720+
.0
1721+
}
1722+
1723+
fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
17081724
let mut encoder = opaque::Encoder::new(vec![]);
17091725
encoder.emit_raw_bytes(METADATA_HEADER);
17101726

0 commit comments

Comments
 (0)