]> git.lizzy.rs Git - rust.git/commit
Auto merge of #26326 - nikomatsakis:optimize-fulfillment-cache-in-tcx, r=pcwalton
authorbors <bors@rust-lang.org>
Wed, 17 Jun 2015 22:50:17 +0000 (22:50 +0000)
committerbors <bors@rust-lang.org>
Wed, 17 Jun 2015 22:50:17 +0000 (22:50 +0000)
commit713d9176adc5072afdf0934dc95b868995e867c0
tree56583a3b9d815678628dbd66206798d28cc65653
parent8af39cebc547a946b4ae861854c46c9c9a70a923
parent957935a002aa88adb0f1288a84a0933d06cc297d
Auto merge of #26326 - nikomatsakis:optimize-fulfillment-cache-in-tcx, r=pcwalton

When we successfully resolve a trait reference with no type/lifetime parameters, like `i32: Foo` or `Box<u32>: Sized`, this is in fact globally true. This patch adds a simple global to the tcx to cache such cases. The main advantage of this is really about caching things like `Box<Vec<Foo>>: Sized`. It also points to the need to revamp our caching infrastructure -- the current caches make selection cost cheaper, but we still wind up paying a high cost in the confirmation process, and in particular unrolling out dependent obligations. Moreover, we should probably do caching more uniformly and with a key that takes the where-clauses into account. But that's for later.

For me, this shows up as a reasonably nice win (20%) on Servo's script crate (when built in dev mode). This is not as big as my initial measurements suggested, I think because I was building my rustc with more debugging enabled at the time. I've not yet done follow-up profiling and so forth to see where the new hot spots are. Bootstrap times seem to be largely unaffected.

cc @pcwalton

This is technically a [breaking-change] in that functions with unsatisfiable where-clauses may now yield errors where before they may have been accepted. Even before, these functions could never have been *called* by actual code. In the future, such functions will probably become illegal altogether, but in this commit they are still accepted, so long as they do not rely on the unsatisfiable where-clauses. As before, the functions still cannot be called in any case.
src/librustc/middle/traits/project.rs