Skip to content

JIT: Reconsider how stress modes are randomly applied #83733

Closed

Description

@jakobbotsch

The hash used to compute whether a stress mode is enabled works simply by xor'ing the integer value of the stress mode in the stress enum:

// Get a hash which can be compared with 'weight'
assert(stressArea != 0);
const unsigned hash = (info.compMethodHash() ^ stressArea ^ stressLevel) % MAX_STRESS_WEIGHT;
assert(hash < MAX_STRESS_WEIGHT && weight <= MAX_STRESS_WEIGHT);
return (hash < weight);

That seems like it would have a very bad distribution -- there's only a few dozens of stress modes so this at most affects only the few lowest bits of the hash code, in a very predictable way.

Additionally, reordering members in the enum leads to an entirely different (unrelated) set of stress modes being enabled/disabled. This for example happened in #79283.

I think it would be better if we derived a hash from the string name of each stress mode and then xor'd with that instead (e.g. using HashStringA). That would be more similar to how other randomness is mixed in as well.

Activity

  1. ghost added
    area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
    on Mar 21, 2023
  2. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Mar 21, 2023
  3. added this to the Future milestone on Mar 21, 2023
  4. removed
    untriagedNew issue has not been triaged by the area owner
    on Mar 21, 2023
  5. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Mar 22, 2023
  6. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on May 10, 2023
  7. added a commit that references this issue on May 10, 2023
    c06191e
  8. self-assigned this
    on May 12, 2023
  9. ghost locked as resolved and limited conversation to collaborators on Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions