Skip to content

ParamEnv::def_id is expensive #74865

Closed
Closed
@nnethercote

Description

@nnethercote

ParamEnv::def_id is only used for Chalk, which currently isn't on by default. I tried removing that field, which (among other things) reduces the size of the hot PredicateObligation type from 40 bytes to 32 bytes. Here are some local perf results on Full builds.

ctfe-stress-4-opt
        avg: -3.1%?     min: -3.1%?     max: -3.1%?
unicode_normalization-check
        avg: 3.0%       min: 3.0%       max: 3.0%
ctfe-stress-4-check
        avg: -2.6%?     min: -2.6%?     max: -2.6%?
ctfe-stress-4-debug
        avg: -2.5%?     min: -2.5%?     max: -2.5%?
unicode_normalization-debug
        avg: 2.1%       min: 2.1%       max: 2.1%
piston-image-debug
        avg: -1.6%      min: -1.6%      max: -1.6%
regression-31157-debug
        avg: -1.6%      min: -1.6%      max: -1.6%
encoding-debug
        avg: -1.6%      min: -1.6%      max: -1.6%
deeply-nested-debug
        avg: -1.5%      min: -1.5%      max: -1.5%
webrender-debug
        avg: -1.5%      min: -1.5%      max: -1.5%
cargo-debug
        avg: -1.5%      min: -1.5%      max: -1.5%
serde-check
        avg: -1.5%      min: -1.5%      max: -1.5%
tokio-webpush-simple-debug
        avg: -1.4%      min: -1.4%      max: -1.4%
unicode_normalization-opt
        avg: 1.4%       min: 1.4%       max: 1.4%
serde-debug
        avg: -1.4%      min: -1.4%      max: -1.4%
encoding-opt
        avg: -1.4%      min: -1.4%      max: -1.4%
webrender-wrench-debug
        avg: -1.4%      min: -1.4%      max: -1.4%
issue-46449-debug
        avg: -1.3%      min: -1.3%      max: -1.3%
syn-debug
        avg: -1.3%      min: -1.3%      max: -1.3%
cranelift-codegen-debug
        avg: -1.3%      min: -1.3%      max: -1.3%       
futures-debug
        avg: -1.3%      min: -1.3%      max: -1.3%
futures-check
        avg: -1.3%      min: -1.3%      max: -1.3%
serde-opt
        avg: -1.3%      min: -1.3%      max: -1.3%
clap-rs-debug
        avg: -1.3%      min: -1.3%      max: -1.3%
ripgrep-debug
        avg: -1.3%      min: -1.3%      max: -1.3%
deeply-nested-check
        avg: -1.2%      min: -1.2%      max: -1.2%
hyper-2-debug
        avg: -1.1%      min: -1.1%      max: -1.1%
regex-debug
        avg: -1.1%      min: -1.1%      max: -1.1%
deep-vector-debug
        avg: -1.1%      min: -1.1%      max: -1.1%

(The unicode_normalization regression is weird, because this change results in the code clearly doing less work overall. Maybe it's a quirk of inlining or codegen, the kind of thing that may well disappear in the face of other minor changes.)

Is this field really needed?

cc @rust-lang/wg-compiler-performance

Metadata

Metadata

Assignees

Labels

C-enhancementCategory: An issue proposing an enhancement or a PR with one.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