revise metadata hashing to hash the contents of the metadata, not its input dependencies #38114
Labels
A-incr-comp
Area: Incremental compilation
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Milestone
NB: Part of the roadmap issue on incremental compilation.
Newer writeup:
The plan is to change how we hash metadata. Instead of hashing the hashes of the predecessors of the metadata node, we ought to hash the metadata content itself. This would be far more robust in general.
Older writeup:
While playing around with an incremental-enabled rustc, I noticed the following pattern.
This can be produced with this test case:
You can observe this if you run twice with the
-Z incremental-dump-hash
option added by #38113:The reason for this problem is that, in the first run, we have to predefine various symbols, which causes us to do associated type normalization, which adds edges to some
TraitSelect
nodes. However, in the second run, because we are able to reuse, we don't do those normalizations, and thus we have fewer edges in the graph.This interacts poorly with our metadata hashing scheme, because the MIR for
push_str
depends onTraitSelect
. Thus when we compute the hash of its metadata, we find the (transitive) sources for that metadata, which means all predecessors ofTraitSelect
. In the first round, this is a different set from the second round. You can see this by diffing the output a bit more:In my opinion, the best fix for this is probably to change how we hash metadata. Instead of hashing the hashes of the predecessors of the metadata node, we ought to hash the metadata content itself. This would be far more robust in general.
cc @michaelwoerister
The text was updated successfully, but these errors were encountered: