-
Notifications
You must be signed in to change notification settings - Fork 1.8k
optimize hash switch generation #2161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
I've just fixed the formatting and unused imports. I'm not sure why |
|
|
|
It seems to be a new test with some possibly overly strong assumptions. I've reported it but it seems like it might be specific to the JDK used in the travis gate as we don't see it in our internal gates, which use slightly different JDK versions. You could add an Ignore to that test so the gate can complete if you like but since I'll run it through our gate it shouldn't be necessary. |
compiler/src/org.graalvm.compiler.lir/src/org/graalvm/compiler/lir/hashing/IntHasher.java
Outdated
Show resolved
Hide resolved
|
I've just fixed the copyright header and rebased. @erik1iu @tkrodriguez please let me know if there's anything missing, I wanted to create a PR that depends on this change. Thank you |
|
This looks ok to me. I'm running it through our gate now. It looks like checkstyle is unhappy with the final modifier on the static methods. |
|
Looks good. BTW, You can use |
|
thanks for the quick replies. I've just removed the unnecessary |
Problem
The hash function generation introduced by #895 has a few problems:
Solution
I started optimizing the hash function generation and observed a pattern. The most successful functions were the ones that involved multiplication by a prime number. That led me to a simpler approach using just a prime factor and a shift.
The new hash function generation returns very fast and covers many more cases than the previous implementation. It can't handle well sets with larger cardinalities but that shouldn't be a problem since the function generation is fast and it would be discarded by
LIRGenerator.emitStrategySwitchbecause of the low density of the table.Notes
JumpTableannotation to reflect the correct size of the entriesTypeSwitches using the hash table approach. I'm using aLongHashervery similar to theIntHasherand it also works well with memory addresses.