Auto merge of #80071 - jyn514:timings, r=Mark-Simulacrum

Add more timing info to rustdoc

This helped me confirm in https://github.com/rust-lang/rust/issues/79103#issuecomment-745737864 that get_blanket_impls is indeed what's taking all the time on stm32.

r? `@Mark-Simulacrum`
This commit is contained in:
bors 2020-12-22 16:09:59 +00:00
commit 353f3a3846
2 changed files with 26 additions and 19 deletions

View File

@ -558,10 +558,13 @@ crate fn get_auto_trait_and_blanket_impls(
ty: Ty<'tcx>,
param_env_def_id: DefId,
) -> impl Iterator<Item = Item> {
AutoTraitFinder::new(cx)
.get_auto_trait_impls(ty, param_env_def_id)
.into_iter()
.chain(BlanketImplFinder::new(cx).get_blanket_impls(ty, param_env_def_id))
let auto_impls = cx.sess().time("get_auto_trait_impls", || {
AutoTraitFinder::new(cx).get_auto_trait_impls(ty, param_env_def_id)
});
let blanket_impls = cx.sess().time("get_blanket_impls", || {
BlanketImplFinder::new(cx).get_blanket_impls(ty, param_env_def_id)
});
auto_impls.into_iter().chain(blanket_impls)
}
crate fn register_res(cx: &DocContext<'_>, res: Res) -> DefId {

View File

@ -16,13 +16,13 @@ crate const COLLECT_TRAIT_IMPLS: Pass = Pass {
crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
let mut synth = SyntheticImplCollector::new(cx);
let mut krate = synth.fold_crate(krate);
let mut krate = cx.sess().time("collect_synthetic_impls", || synth.fold_crate(krate));
let prims: FxHashSet<PrimitiveType> = krate.primitives.iter().map(|p| p.1).collect();
let crate_items = {
let mut coll = ItemCollector::new();
krate = coll.fold_crate(krate);
krate = cx.sess().time("collect_items_for_trait_impls", || coll.fold_crate(krate));
coll.items
};
@ -39,16 +39,18 @@ crate fn collect_trait_impls(krate: Crate, cx: &DocContext<'_>) -> Crate {
// Also try to inline primitive impls from other crates.
for &def_id in PrimitiveType::all_impls(cx.tcx).values().flatten() {
if !def_id.is_local() {
inline::build_impl(cx, None, def_id, None, &mut new_items);
cx.sess().time("build_primitive_trait_impl", || {
inline::build_impl(cx, None, def_id, None, &mut new_items);
// FIXME(eddyb) is this `doc(hidden)` check needed?
if !cx.tcx.get_attrs(def_id).lists(sym::doc).has_word(sym::hidden) {
let self_ty = cx.tcx.type_of(def_id);
let impls = get_auto_trait_and_blanket_impls(cx, self_ty, def_id);
let mut renderinfo = cx.renderinfo.borrow_mut();
// FIXME(eddyb) is this `doc(hidden)` check needed?
if !cx.tcx.get_attrs(def_id).lists(sym::doc).has_word(sym::hidden) {
let self_ty = cx.tcx.type_of(def_id);
let impls = get_auto_trait_and_blanket_impls(cx, self_ty, def_id);
let mut renderinfo = cx.renderinfo.borrow_mut();
new_items.extend(impls.filter(|i| renderinfo.inlined.insert(i.def_id)));
}
new_items.extend(impls.filter(|i| renderinfo.inlined.insert(i.def_id)));
}
})
}
}
@ -151,11 +153,13 @@ impl<'a, 'tcx> DocFolder for SyntheticImplCollector<'a, 'tcx> {
if i.is_struct() || i.is_enum() || i.is_union() {
// FIXME(eddyb) is this `doc(hidden)` check needed?
if !self.cx.tcx.get_attrs(i.def_id).lists(sym::doc).has_word(sym::hidden) {
self.impls.extend(get_auto_trait_and_blanket_impls(
self.cx,
self.cx.tcx.type_of(i.def_id),
i.def_id,
));
self.cx.sess().time("get_auto_trait_and_blanket_synthetic_impls", || {
self.impls.extend(get_auto_trait_and_blanket_impls(
self.cx,
self.cx.tcx.type_of(i.def_id),
i.def_id,
));
});
}
}