Skip to content

Commit

Permalink
Prefetch queries used by the metadata encoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Mar 19, 2020
1 parent 3c6f982 commit 6cd0dca
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/librustc_metadata/rmeta/encoder.rs
Expand Up @@ -18,7 +18,7 @@ use rustc_ast::attr;
use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::StableHasher;
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::sync::{join, par_for_each_in, Lrc};
use rustc_hir as hir;
use rustc_hir::def::CtorKind;
use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE};
Expand Down Expand Up @@ -1721,6 +1721,22 @@ impl<'tcx, 'v> ItemLikeVisitor<'v> for ImplVisitor<'tcx> {
// generated regardless of trailing bytes that end up in it.

pub(super) fn encode_metadata(tcx: TyCtxt<'_>) -> EncodedMetadata {
join(
|| encode_metadata_impl(tcx),
|| {
// Prefetch some queries used by metadata encoding
tcx.dep_graph.with_ignore(|| {
par_for_each_in(tcx.mir_keys(LOCAL_CRATE), |&def_id| {
tcx.optimized_mir(def_id);
tcx.promoted_mir(def_id);
});
})
},
)
.0
}

fn encode_metadata_impl(tcx: TyCtxt<'_>) -> EncodedMetadata {
let mut encoder = opaque::Encoder::new(vec![]);
encoder.emit_raw_bytes(METADATA_HEADER);

Expand Down

0 comments on commit 6cd0dca

Please sign in to comment.