Skip to content

Optimizing rustc: replace HashMap with OrderMap? #45273

Closed
@ghost

Description

Just for fun, I tried changing

pub type FxHashMap<K, V> = HashMap<K, V, BuildHasherDefault<FxHasher>>;

to

pub type FxHashMap<K, V> = OrderMap<K, V, BuildHasherDefault<FxHasher>>;

Using the new compiler, compilation time of my crate went down from 28.24 seconds to 25.46 seconds. I didn't do any further benchmarks yet, but the results seem promising. Looks like we could easily shave 5-10% from compilation time simply by changing the hash map implementation.

I was wondering if anyone else considered doing the same, and whether this is something I should experiment with further? What do you think?

cc @bluss

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-compiletimeIssue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions