Skip to content

Use another hashing algorithm? 250K calls to Siphash #15649

@blyxyas

Description

@blyxyas

While profiling Clippy I came accross 250k calls to <core::hash::sip::Hasher<core::hash::sip::Sip13Rounds> as core::hash::Hasher>::write, and they turn out to be the most time-consuming by themselves (at least that's what callgrind says), all of them coming from Cargo.

These numbers in particular is from bumpalo-3.16.0

The 4 callers of this function are from hashing &url::Url (hash_one -> 26 296 times), hashing &semver::Version (hash_one -> 83 342x), hashing package_id::PackageId (hash -> 48 554x) and dependency::Dependency (hash -> 31 099x)

To reproduce

cd bumpalo-3.16.0
CARGO_TARGET_DIR=/tmp/m1 valgrind --tool=callgrind --dump-instr=yes --collect-jumps=yes --trace-children=yes /home/meow/.rustup/toolchains/nightly-2025-05-31-x86_64-unknown-linux-gnu/bin/cargo clippy

Note that this is without incremental compilation, thus the CARGO_TARGET_DIR env var.

I'm not sure if there's a reason why Cargo uses the default hasher.

Metadata

Metadata

Assignees

No one assigned

    Labels

    PerformanceGotta go fast!S-needs-mentorStatus: Issue or feature is accepted, but needs a team member to commit to helping and reviewing.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions