Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up🛠 improve canonicalization by using a hashing scheme #48417
Comments
nikomatsakis
changed the title
improve canonicalization by using a hashing scheme
🛠 improve canonicalization by using a hashing scheme
Feb 25, 2018
This comment has been minimized.
This comment has been minimized.
|
That said, in all profiles I've looked at, canonicalization doesn't seem to be a hot spot. |
jkordish
added
the
C-enhancement
label
Apr 23, 2018
This comment has been minimized.
This comment has been minimized.
JaimeValdemoros
commented
May 29, 2018
•
|
Hi @nikomatsakis! I'm keen to have a look at this if you don't mind giving me a couple of hints along the way? I have some rust experience but this would be my first time contributing to the compiler. |
This comment has been minimized.
This comment has been minimized.
JaimeValdemoros
commented
May 29, 2018
•
|
I had an initial go a adding the |
This comment has been minimized.
This comment has been minimized.
|
@JaimeValdemoros Are you still working on this? If you make a pull request (even if it's not "finished" or "ready") then it will be much easier for everyone to see your code (rather than getting GitHub to diff your branch against rust/master directly). |
nikomatsakis
added
WG-compiler-nll
NLL-performant
labels
Jun 26, 2018
This comment has been minimized.
This comment has been minimized.
|
I'm tagging this with WG-compiler-nll and NLL-performant since this is also an important issue for non-lexical lifetimes. canonicalization takes about 5% of NLL time. |
JaimeValdemoros
referenced this issue
Jun 27, 2018
Closed
[WIP] improve canonicalization by using a hashing scheme #51837
This comment has been minimized.
This comment has been minimized.
JaimeValdemoros
commented
Jun 27, 2018
|
Sorry about the delay - I'm still keen give this a shot! I've just made a PR here: #51837 following @technicalguy's suggestion. |
This comment has been minimized.
This comment has been minimized.
|
@JaimeValdemoros, @technicalguy -- think you two could join the rust-lang Zulip? I've created a thread where we could chat about this. |
This comment has been minimized.
This comment has been minimized.
|
Current measurements are showing canonicalization as 11% of NLL check, with the latest optimizations, so this is becoming increasingly relevant. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis I think I have joined Zulip now...yet another chat application! |
nikomatsakis
added this to the Rust 2018 Release Candidate milestone
Jul 3, 2018
nikomatsakis
referenced this issue
Jul 17, 2018
Merged
Avoid most allocations in `Canonicalizer`. #52342
This comment has been minimized.
This comment has been minimized.
|
So, this is a big refactoring, and my measurements suggest that while it would help NLL, it would not make a huge difference. I'm going to remove this from the milestone. |
nikomatsakis
removed this from the Rust 2018 RC milestone
Aug 8, 2018
nikomatsakis
added
NLL-deferred
and removed
NLL-deferred
NLL-performant
labels
Aug 8, 2018
This comment has been minimized.
This comment has been minimized.
|
Perhaps, in any case, this was a bit much too chew at once, I'm going to see if I can break it down into smaller steps. |
nikomatsakis commentedFeb 22, 2018
The canonicalization scheme created in #48411 works by first folding types into a canonical form, which is then hashed and interned. This is not necessary, and it shows up in the profiles: we could augment the
TypeFoldertrait to have a method for hashing as it goes (e.g., ahash_withmethod, and somehash_ty/hash_regioncallbacks). Then we can begin by hashing the value-to-be-canonicalized, producing a hash (this would be a kind of "stable hash", hence big enough to be presumed unique). We would then look for an interned value with that hash and return it if found, avoiding all the folding. If no interned value is found, then we would fold and put the resulting value into the interning table. Ideally, this hash can then be kept for later, making the "stable hash" code quite cheap.(This might actually not make things faster, of course, we would want to measure.)