[Incremental] Cache hashes for AdDef and ty::Slice<T>#47373
[Incremental] Cache hashes for AdDef and ty::Slice<T>#47373bors merged 2 commits intorust-lang:masterfrom
Conversation
src/librustc/ich/impls_ty.rs
Outdated
There was a problem hiding this comment.
Can you check this? I tried self as *const ty::Slice<T> as usize but got a casting error. The suggested fix in #41300 resolved the error but I'm not really sure why it works.
src/librustc/ty/mod.rs
Outdated
There was a problem hiding this comment.
Since AdtDefs are not recursive, you should be able to slightly optimize this by using HashMap::entry(). That avoids having to look up the key twice in the "cache miss" case.
You cannot do the same for ty::Slice because while hashing one slice, you might encounter a nested one somewhere down the line and consequently run into a RefCell double-borrow panic.
src/librustc/ty/mod.rs
Outdated
There was a problem hiding this comment.
I would move this whole block into the closure, after the "cache hit" case.
|
Right, a What you did should be correct but is a bit roundabout. First you are converting I would suggest that you do the same thing as the Line 571 in 73ac5d6 This makes use of the Since the So I would make the cache key |
|
|
c8adecd to
eab3bfc
Compare
|
Thanks @michaelwoerister! I think I've addressed all of your concerns in the latest revisions. |
michaelwoerister
left a comment
There was a problem hiding this comment.
Looks good! If you remove that redundant line I commented on below, this should be ready for a performance test.
src/librustc/ty/mod.rs
Outdated
There was a problem hiding this comment.
This line seems to be a leftover from something.
There was a problem hiding this comment.
Oops, I'm not even sure where that came from lol
eab3bfc to
45bd091
Compare
|
Fixed |
|
Excellent. I'll start a try-build so we can measure the performance impact. @bors try |
[Incremental] Cache hashes for AdDef and ty::Slice<T> r? @michaelwoerister
|
☀️ Test successful - status-travis |
|
Perf queued. |
|
perf.rlo link ( |
|
Nice! These are some pretty good performance improvements. If it doesn't cause any trouble with further testing, we might even want to backport it to the current beta, given how small the change set is. Thank you, @wesleywiser! @bors r+ |
|
📌 Commit 45bd091 has been approved by |
|
Thanks @michaelwoerister! |
…ster [Incremental] Cache hashes for AdDef and ty::Slice<T> r? @michaelwoerister
|
☀️ Test successful - status-appveyor, status-travis |
|
Very good numbers for a single optimization |
r? @michaelwoerister