Skip to content

Code generation issue blocks the removal of an unused struct field #77058

Closed
@vandenheuvel

Description

@vandenheuvel

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-bugCategory: This is a bug.I-compiletimeIssue: Problems and improvements with respect to compile times.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions