-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
[SPARK-19999]: Workaround JDK-8165231 to identify PPC64 architectures as supporting unaligned access #17472
Closed
Closed
[SPARK-19999]: Workaround JDK-8165231 to identify PPC64 architectures as supporting unaligned access #17472
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bcef03d
SPARK-19999 - fix jdk bug
samelamin 8785664
indentation keeps changing because of intellij
samelamin 799effa
set default indentation to 2
samelamin bf7cc24
move and clarify comment
samelamin 77777e9
define arch befote if statement
samelamin 632161b
use equals as per feedback from pr
selamin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,18 +46,22 @@ public final class Platform { | |
private static final boolean unaligned; | ||
static { | ||
boolean _unaligned; | ||
// use reflection to access unaligned field | ||
try { | ||
Class<?> bitsClass = | ||
Class.forName("java.nio.Bits", false, ClassLoader.getSystemClassLoader()); | ||
Method unalignedMethod = bitsClass.getDeclaredMethod("unaligned"); | ||
unalignedMethod.setAccessible(true); | ||
_unaligned = Boolean.TRUE.equals(unalignedMethod.invoke(null)); | ||
} catch (Throwable t) { | ||
// We at least know x86 and x64 support unaligned access. | ||
String arch = System.getProperty("os.arch", ""); | ||
//noinspection DynamicRegexReplaceableByCompiledPattern | ||
_unaligned = arch.matches("^(i[3-6]86|x86(_64)?|x64|amd64|aarch64)$"); | ||
String arch = System.getProperty("os.arch", ""); | ||
if (arch.matches("^(ppc64le | ppc64)$")) { | ||
// Since java.nio.Bits.unaligned() doesn't return true on ppc (See JDK-8165231), but ppc64 and ppc64le support it | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is longer than 101 characters. It will fail the style test. You can check it in your local environment using the command:
|
||
_unaligned = true; | ||
} else { | ||
try { | ||
Class<?> bitsClass = | ||
Class.forName("java.nio.Bits", false, ClassLoader.getSystemClassLoader()); | ||
Method unalignedMethod = bitsClass.getDeclaredMethod("unaligned"); | ||
unalignedMethod.setAccessible(true); | ||
_unaligned = Boolean.TRUE.equals(unalignedMethod.invoke(null)); | ||
} catch (Throwable t) { | ||
// We at least know x86 and x64 support unaligned access. | ||
//noinspection DynamicRegexReplaceableByCompiledPattern | ||
_unaligned = arch.matches("^(i[3-6]86|x86(_64)?|x64|amd64|aarch64)$"); | ||
} | ||
} | ||
unaligned = _unaligned; | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, why not
arch.startsWith("ppc64")
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title changed, but I dont have access to change the jira title?
Re string matching - Thats fine but itll end up being arch.startsWith("ppc64") || arch.startsWith("ppc64le")
I thought this was less code, but startsWith is more readable
Are you happy with that approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of those start with ppc64, what do you mean? I guess my question is, is there a big-endian PPC64 arch?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah sorry complete fail, didnt see that lol
With regards to a big-endian PPC64 arch , I dont think so but I am not 100% sure. that said as it stands it isn't supported and the test fails. So happy to change the PR or even close it if you do not see any value it adds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm writing one thing and thinking another. I mean alignment, not endianness. Which architectures do you know allow unaligned access? I'd presume all PPC does, and I assume the JDK issue means "PPC64 (big-endian) but also PPC64 little-endian". OK, to be conservative, maybe just check the strings "ppc64" and "ppc64le" as you intended.
However your regex doesn't work. You have extra whitespace. Just instead check
arch.equals(...) || arch.equals(...)
Also the PR title shoudl match the JIRA title. I was commenting that it differed here in referring to a flaky test, but it isn't. To be very clear, I propose you rename both to perhaps: "Workaround JDK-8165231 to identify PPC64 architectures as supporting unaligned access"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha its fine, called it rubber duck programming eh
Sure I will make those changes, but I have no rights to rename the JIRA
So I will rename this PR, can you get yourself or someone to rename the JIRA?