Skip to content
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
wants to merge 6 commits into from

Conversation

samelamin
Copy link
Contributor

@samelamin samelamin commented Mar 29, 2017

java.nio.Bits.unaligned() does not return true for the ppc64le arch.
see https://bugs.openjdk.java.net/browse/JDK-8165231

What changes were proposed in this pull request?

check architecture

How was this patch tested?

unit test

_unaligned = Boolean.TRUE.equals(unalignedMethod.invoke(null));

//Since java.nio.Bits.unaligned() doesn't return true on ppc (See JDK-8165231)
if(arch.matches("^(ppc64le|ppc64)$")){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to add appropriate space between words?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can perform this check up top? you don't need to do all the reflection here if the arch matches. Also is it true that anything starting with "ppc64" should be special-cased?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved up top.


//Since java.nio.Bits.unaligned() doesn't return true on ppc (See JDK-8165231)
if(arch.matches("^(ppc64le|ppc64)$")){
_unaligned=true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spark uses two spaces for an indent.

@samelamin
Copy link
Contributor Author

@kiszk @srowen updated per your commets

_unaligned = Boolean.TRUE.equals(unalignedMethod.invoke(null));
} catch (Throwable t) {
// We at least know x86 and x64 support unaligned access.
boolean _unaligned;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent issues.

Please follow the style guide: https://github.com/databricks/scala-style-guide#indent

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its to do with my local setup, i dont see the issues in Intellij, sorry! :(

ill revert my changes and try again

@samelamin
Copy link
Contributor Author

@gatorsmile I think my Intellij has some annoying auto indenting changes. Does spark have some project wide settings I can auto import?

@gatorsmile
Copy link
Member

I do not think we have such a default steup. You can manually change the indentation of InteiiJ

@samelamin
Copy link
Contributor Author

ok @gatorsmile i set default indentation to 2, how does it look now?

if (arch.matches("^(ppc64le | ppc64)$")) {
_unaligned = true;
} else {
//Since java.nio.Bits.unaligned() doesn't return true on ppc (See JDK-8165231)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving this comment to line 50?

Maybe you also need to explain it more clearly.

Since java.nio.Bits.unaligned() doesn't return true on ppc (See JDK-8165231), but ppc64 and ppc64le support it

@samelamin
Copy link
Contributor Author

@gatorsmile moved the comment per your suggestion, but to be honest if the comment is unclear surly the first thing someone will do is check that JIRA?

//noinspection DynamicRegexReplaceableByCompiledPattern
_unaligned = arch.matches("^(i[3-6]86|x86(_64)?|x64|amd64|aarch64)$");
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
Copy link
Member

Choose a reason for hiding this comment

The 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:

dev/lint-scala

@gatorsmile
Copy link
Member

ok to test

@gatorsmile
Copy link
Member

Clear code comments can help code reading. : )

@SparkQA
Copy link

SparkQA commented Mar 29, 2017

Test build #75372 has finished for PR 17472 at commit bf7cc24.

  • This patch fails to build.
  • This patch merges cleanly.
  • This patch adds no public classes.

_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", "");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we define arch before the if statement, now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

your absolutely right, I got caught off while I was trying to fix the indentation issues. good catch!

@SparkQA
Copy link

SparkQA commented Mar 30, 2017

Test build #75380 has started for PR 17472 at commit 77777e9.

@samelamin
Copy link
Contributor Author

jenkins test this please

@samelamin
Copy link
Contributor Author

Can someone guide me why the tests failed? is it another flakey test or? because the below message doesnt make sense to me :(

Traceback (most recent call last):
File "./dev/run-tests-jenkins.py", line 226, in
main()
File "./dev/run-tests-jenkins.py", line 213, in main
test_result_code, test_result_note = run_tests(tests_timeout)
File "./dev/run-tests-jenkins.py", line 140, in run_tests
test_result_note = ' * This patch fails %s.' % failure_note_by_errcode[test_result_code]
KeyError: -9

Copy link
Member

@srowen srowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the test failure is unrelated. The title of the JIRA/PR should be changed; they aren't flaky tests. You're trying to accommodate a new architecture that isn't really supported.

//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)$")) {
Copy link
Member

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")?

Copy link
Contributor Author

@samelamin samelamin Mar 30, 2017

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?

Copy link
Member

@srowen srowen Mar 30, 2017

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?

Copy link
Contributor Author

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

Copy link
Member

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"

Copy link
Contributor Author

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?

@samelamin samelamin changed the title [SPARK-19999]: Fix for flakey tests due to java.nio.Bits.unaligned() … [SPARK-19999]: Accommodate a new architecture that is not supported. Mar 30, 2017
@samelamin samelamin changed the title [SPARK-19999]: Accommodate a new architecture that is not supported. [SPARK-19999]: Workaround JDK-8165231 to identify PPC64 architectures as supporting unaligned access Mar 30, 2017
@SparkQA
Copy link

SparkQA commented Mar 30, 2017

Test build #75386 has finished for PR 17472 at commit 632161b.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

@samelamin
Copy link
Contributor Author

@gatorsmile @srowen how does it look now?

@gatorsmile
Copy link
Member

LGTM

@srowen
Copy link
Member

srowen commented Mar 30, 2017

Merged to master

@asfgit asfgit closed this in 258bff2 Mar 30, 2017
kiszk added a commit to kiszk/spark that referenced this pull request Apr 2, 2017
asfgit pushed a commit that referenced this pull request Apr 2, 2017
…PPC64 architectures as supporting unaligned access

## What changes were proposed in this pull request?

This PR is backport of #17472 to Spark 2.1

java.nio.Bits.unaligned() does not return true for the ppc64le arch.
see [https://bugs.openjdk.java.net/browse/JDK-8165231](https://bugs.openjdk.java.net/browse/JDK-8165231)
Check architecture in Platform.java

## How was this patch tested?

unit test

Author: Kazuaki Ishizaki <[email protected]>

Closes #17509 from kiszk/branch-2.1.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants