Description
The unused_field
field of type Option<DefId>
in ParamEnv
is not used but removing the field has a strange and undesired effect on compiler performance.
When the field is removed, performance changes as in #74865 are observed: an instruction count gain of about 1% across all tests, with the unicode_* tests demonstrating a 3% increase, even though, in principle, less work should be done if the unused field is not copied around. Worse, the 3% instruction count increase corresponds to a 25% percent increase in wall-time, moreover suggesting that something is going wrong.
Interestingly, changing the type of Option<DefId>
, which is 8 bytes long, with an unused field of type [u8; 8]
, has a performance impact. The conversation at #76913 contains several perf runs that are relevant.
Once the code generation issue is resolved and the field is removed, a performance gain of about 1% is expected to be realized.