Skip to content

Add an unstable 'extra randomization' compile-time flag for hashers #65042

Open
@Aaron1011

Description

@Aaron1011

When working on #64906, I ran into a latent dependency on the iteration order of a HashMap. This resulted in the PR becoming unmergeable - since a FxHashMap was being used, the iteration order ended up differing between platforms, which made it impossible to make the tests pass on all platforms.

It would be nice to have a way of exposing these kinds of hidden ordering dependencies before they result in blocked PRs.

I propose the following:

  • Add a new feature called randomize_iteration to std and fxhash. When enabled, this feature will cause the iteration order of iter and iter_mut to be randomized per call.
  • Add a config.toml key to enable both of these features.

This will allow producing a special build of the compiler that will (hopefully) expose many hidden ordering dependencies. The overhead could be very high, but that shouldn't matter too much - the only purpose of this build would be to run the testsuite.

Once std-aware Cargo is fully implement, we could consider making this usable by user-written crates (e.g. allowing people to opt-in to recompiling std in this mode).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-reproducibilityArea: Reproducible / deterministic buildsA-testsuiteArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.C-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-bootstrapRelevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)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