Skip to content

Commit 678af41

Browse files
Merge #8514
8514: Add more profiling spans into type inference r=matklad a=SomeoneToIgnore Fixes #8503 I've added a minimal set of spans to remove `???` and showcase the underlying issue: <img width="1552" alt="image" src="https://user-images.githubusercontent.com/2690773/114722983-f2181900-9d42-11eb-821d-9e93ded5f81f.png"> `db.trait_solve` reliably produces the same timings for the same input in the same place for me, despite supposedly being cached by Salsa. In my perception, this is a bit odd, so I've decided to stop at this point and discuss it with people with better knowledge on the topic. Co-authored-by: Kirill Bulatov <[email protected]>
2 parents 10a243e + 75a2605 commit 678af41

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

crates/hir_ty/src/autoderef.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ pub(crate) fn deref(
3636
krate: CrateId,
3737
ty: InEnvironment<&Canonical<Ty>>,
3838
) -> Option<Canonical<Ty>> {
39+
let _p = profile::span("deref");
3940
if let Some(derefed) = builtin_deref(&ty.goal.value) {
4041
Some(Canonical { value: derefed, binders: ty.goal.binders.clone() })
4142
} else {
@@ -56,6 +57,7 @@ fn deref_by_trait(
5657
krate: CrateId,
5758
ty: InEnvironment<&Canonical<Ty>>,
5859
) -> Option<Canonical<Ty>> {
60+
let _p = profile::span("deref_by_trait");
5961
let deref_trait = match db.lang_item(krate, "deref".into())? {
6062
LangItemTarget::TraitId(it) => it,
6163
_ => return None,
@@ -83,7 +85,10 @@ fn deref_by_trait(
8385
environment: ty.environment.clone(),
8486
},
8587
};
86-
if db.trait_solve(krate, implements_goal).is_none() {
88+
if {
89+
let _p = profile::span("db.trait_solve");
90+
db.trait_solve(krate, implements_goal).is_none()
91+
} {
8792
return None;
8893
}
8994

0 commit comments

Comments
 (0)