Use Rc instead of Box for interned strings. by nnethercote · Pull Request #50549 · rust-lang/rust (original) (raw)

We currently heap-allocate each one twice, once for Interner::names and
once for Interner::strings. Using Rc instead means each one is allocated
once and then shared.

This speeds up numerous rustc-perf runs, the best by 4%.

Here are details for the ones with an improvement of 1% or more:

coercions-check
        avg: -2.3%      min: -4.1%      max: -0.8%
coercions
        avg: -1.3%      min: -2.8%      max: -0.8%
coercions-opt
        avg: -1.5%      min: -2.7%      max: -0.6%
tuple-stress
        avg: -0.5%      min: -1.3%      max: 0.1%
tuple-stress-check
        avg: -0.6%      min: -1.3%      max: -0.3%
tuple-stress-opt
        avg: -0.7%      min: -1.3%      max: -0.4%