eclipse-openj9 / openj9

Eclipse OpenJ9: A Java Virtual Machine for OpenJDK that's optimized for small footprint, fast start-up, and high throughput. Builds on Eclipse OMR (https://github.com/eclipse/omr) and combines with the Extensions for OpenJDK for OpenJ9 repo.
Other
3.28k stars 721 forks source link

Improve ThreadInfoBase.hashCode() #6064

Open pdbain-ibm opened 5 years ago

pdbain-ibm commented 5 years ago

The current code is expensive, since it is based on the member fields and is recomputed every time. It also uses the sum of several small integers weighted equally.

Suggested improvements:

  1. compute the value lazily and cache it for further use
  2. assign different weights to boolean and numeric components, especially those likely to be small integers like waitedCount and threadId.
  3. explicitly invoke the hashCode() for string components.

@keithc-ca you know much more about this than I do: your suggestions are welcome.

pshipton commented 5 years ago

ThreadInfoBase refers to #5964, which at this time hasn't been merged yet.

pdbain-ibm commented 5 years ago

Note that ThreadInfoBase uses ThreadInfo's hashCode() implementation.