Uh oh!
There was an error while loading. Please reload this page.
Performance audit, Spring 2017 - #41410
Conversation
rust-highfive
commented
Apr 20, 2017
(rust_highfive has picked a reviewer for you, use r? to override) |
KalitaAlexey
commented
Apr 20, 2017
@arielb1, |
arielb1
commented
Apr 20, 2017
I'm doing measurements locally, but after this is done it'll show up on perf.rust-lang.org (or the mirror https://perf-rlo.herokuapp.com). |
This improves LLVM performance by 10% lost during the shimmir transition.
this improves typeck & trans performance by 1%. This looked hotter on callgrind than it is on a CPU.
ce14cf8 to
c8fe505Comparemichaelwoerister
commented
Apr 20, 2017
WOW! |
c8fe505 to
71d3270Compare| (self.tcx().mk_region(ty::ReStatic), | ||
| self.tcx().mk_region(ty::ReStatic)) | ||
| (self.tcx().types.re_static, | ||
| self.tcx().types.re_static) |
There was a problem hiding this comment.
I just noticed that we don't have these constants pre-interned. This is going to conflict like hell with one of my in-progress branches, but oh well. =)
nikomatsakis
left a comment
There was a problem hiding this comment.
r=me on the stuff so far
| value, amount); | ||
| value.fold_with(&mut RegionFolder::new(tcx, &mut false, &mut |region, _current_depth| { | ||
| tcx.mk_region(shift_region(*region, amount)) |
There was a problem hiding this comment.
Oh wow. By-value shift_region may have been used by elision or something. Can we just kill it?
| pub fn field<C: LayoutTyper<'tcx>>(&self, cx: C, i: usize) -> C::TyLayout { | ||
| cx.layout_of(self.field_type(cx, i)) | ||
| cx.layout_of(cx.normalize_associated_type(self.field_type(cx, i))) |
There was a problem hiding this comment.
Why do you need to do it here, when layout_of does it at the start?
There was a problem hiding this comment.
now it doesn't. types in trans are always normalized.
| return TyLayout { ty: ty, layout: layout, variant_index: None }; | ||
| } | ||
| self.tcx().infer_ctxt((), traits::Reveal::All).enter(|infcx| { |
There was a problem hiding this comment.
Is creating the infer_ctxt costly?
There was a problem hiding this comment.
Can you (trans-)normalize before checking the cache above? Would that solve the problem?
There was a problem hiding this comment.
I'd still like to get rid of the normalize_associated_type method - can't field_of rely on layout_of normalizing before checking the cache? if !ty.has_projection_types() { is really fast, right?
There was a problem hiding this comment.
Except when there are projection types (nested binders) etc. This method is hot.
There was a problem hiding this comment.
Is has_projection_types anything other than a flag check? I'm not sure I understand what's going on. Can the cache be hit with the unnormalized type if has_projection_types returns true?
| ref item => bug!("trait_impl_polarity: {:?} not an impl", item) | ||
| } | ||
| } else { | ||
| self.sess.cstore.impl_polarity(id) |
There was a problem hiding this comment.
Can you remove the CrateStore method? They keep piling up.
There was a problem hiding this comment.
I'm not sure this commit does what it's supposed to.
| } | ||
| } | ||
| impl<T> Rc<[T]> { |
There was a problem hiding this comment.
Out of curiosity, for the purposes of the compiler, does Rc<[T]> provide a measurable improvement over Rc<Vec<T>>?
There was a problem hiding this comment.
This may also be more easily implementable by consuming Vec<T> as you've got to copy data anyway. With Vec<T> the box_free also doesn't need to be exposed as you can just .set_len(0) to drop all the elements.
There was a problem hiding this comment.
Didn't bother checking. But Rc<Vec<T>> is too ugly to me.
82092ca to
c357febComparearielb1
commented
Apr 20, 2017
I think this is enough for one PR. |
That method is *incredibly* hot, so this ends up saving 10% of trans time. BTW, we really should be doing dependency tracking there - and possibly be taking the respective perf hit (got to find a way to make DTMs fast), but `layout_cache` is a non-dep-tracking map.
c357feb to
f964da5Compareeddyb
commented
Apr 20, 2017
@bors r=nikomatsakis,eddyb |
bors
commented
Apr 20, 2017
📌 Commit f964da5 has been approved by |
…nikomatsakis,eddyb Performance audit, Spring 2017 Fix up some quite important performance "surprises" I've found running callgrind on rustc. This really should land in 1.18.
eddyb
commented
Apr 20, 2017
@bors r- Build failed. |
| unsafe fn box_free<T: ?Sized>(ptr: *mut T) { | ||
| pub(crate) unsafe fn box_free<T: ?Sized>(ptr: *mut T) { | ||
| let size = size_of_val(&*ptr); | ||
| let align = min_align_of_val(&*ptr); |
There was a problem hiding this comment.
These two functions are not imported during testing (so this fails to compile then).
this avoids parsing item attributes on each call to `item_attrs`, which takes off 33% (!) of translation time and 50% (!) of trans-item collection time.
improves trans performance by *another* 10%.
this improves trans performance by *another* 10%.
this is another one of these things that looks *much* worse on valgrind.
f964da5 to
dae49f1Comparearielb1
commented
Apr 20, 2017
@bors r=eddyb |
bors
commented
Apr 20, 2017
📌 Commit dae49f1 has been approved by |
…eddyb Performance audit, Spring 2017 Fix up some quite important performance "surprises" I've found running callgrind on rustc. This really should land in 1.18.
9cab5fd to
461bee5Comparearielb1
commented
Apr 22, 2017
So now I solved the "specialization caching" problem for real. |
In some cases (e.g. <[int-var] as Add<[int-var]>>), selection can turn up a large number of candidates. Bailing out early avoids O(n^2) performance. This improves item-type checking time by quite a bit, resulting in ~2% of total time-to-typeck.
461bee5 to
1b207caCompareeddyb
commented
Apr 22, 2017
@bors r=nikomatsakis,eddyb |
bors
commented
Apr 22, 2017
📌 Commit 1b207ca has been approved by |
bors
commented
Apr 22, 2017
🔒 Merge conflict |
bors
commented
Apr 22, 2017
☔ The latest upstream changes (presumably #41464) made this pull request unmergeable. Please resolve the merge conflicts. |
arielb1
commented
Apr 22, 2017
Moving the branch over to arielb1/rust. |
Fix up some quite important performance "surprises" I've found running callgrind on rustc.
This really should land in 1.18.