Skip to content

Use NativeAffinity on Mac OS X#45

Merged
peter-lawrey merged 1 commit into
peter-lawrey:masterfrom
danielmitterdorfer:fix-jdk8-mac
Oct 4, 2016
Merged

Use NativeAffinity on Mac OS X#45
peter-lawrey merged 1 commit into
peter-lawrey:masterfrom
danielmitterdorfer:fix-jdk8-mac

Conversation

@danielmitterdorfer

@danielmitterdorfer danielmitterdorfer commented Oct 4, 2016

Copy link
Copy Markdown

With this commit we'll use NativeAffinity again on Mac OS X by fixing the path to the native library. In addition, we include the native library also as a .dylib in order to support JDK 8.

@danielmitterdorfer

danielmitterdorfer commented Oct 4, 2016

Copy link
Copy Markdown
Author

Note that this PR still does not work because there is still a problem with the native library. When acquiring an AffinityLock on Mac OS X, we get:

java.lang.UnsatisfiedLinkError: com.higherfrequencytrading.affinity.impl.NativeAffinity.getAffinity0()J
    at com.higherfrequencytrading.affinity.impl.NativeAffinity.getAffinity0(Native Method)
    at com.higherfrequencytrading.affinity.impl.NativeAffinity.getAffinity(NativeAffinity.java:49)
    at com.higherfrequencytrading.affinity.AffinitySupport.getAffinity(AffinitySupport.java:55)
    at com.higherfrequencytrading.affinity.AffinityLock.<clinit>(AffinityLock.java:44)

The reason is that the dynamic library that is included seems to export old symbols before a package refactoring. If I run nm -gU libaffinity.dylib, I get:

0000000000000afc T _Java_vanilla_java_affinity_impl_NativeAffinity_getAffinity0
0000000000000b75 T _Java_vanilla_java_affinity_impl_NativeAffinity_setAffinity0
0000000000000cb3 T _Java_vanilla_java_busywaiting_impl_JNIBusyWaiting_pause0
0000000000000cc9 T _Java_vanilla_java_busywaiting_impl_JNIBusyWaiting_whileEqual0
0000000000000d26 T _Java_vanilla_java_busywaiting_impl_JNIBusyWaiting_whileLessThan0
0000000000000c75 T _Java_vanilla_java_clock_impl_JNIClock_rdtsc0

However, based on the source code in com_higherfrequencytrading_affinity_impl_NativeAffinity_MacOSX.c, I'd expect symbols like Java_com_higherfrequencytrading_affinity_impl_NativeAffinity_getAffinity0. I have looked at the Makefile in the project to rebuild the binary but there does not seem to be support for Mac OS X(?) and I have no clue how the Mac OS X binary has been built.

@peter-lawrey peter-lawrey merged commit e70f795 into peter-lawrey:master Oct 4, 2016
@peter-lawrey

Copy link
Copy Markdown
Owner

Merged the changes. I don't have a Mac OSX so any assistance you can provide would be appreciated.

@danielmitterdorfer

Copy link
Copy Markdown
Author

@peter-lawrey Sure, I can test but as I've written in the comment above, the dynamic library binary for Mac OS X is outdated and I have no clue how it should be built for Mac OS X (the Makefile seems to be Linux specific?).

@peter-lawrey

Copy link
Copy Markdown
Owner

I had hoped that

A) it had worked for the person who write it
B) Makefiles work much the same on Mac OSX.

If there is a better way for Mac I am open to ideas.

On 4 Oct 2016 11:30, "Daniel Mitterdorfer" notifications@github.com wrote:

@peter-lawrey https://github.com/peter-lawrey Sure, I can test but as
I've written in the comment above, the dynamic library binary for Mac OS X
is outdated and I have no clue how it should be built for Mac OS X (the
Makefile seems to be Linux specific?).


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#45 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABBU8cl6PELfQZ3VMSSxfIlZmhgIhkTJks5qwiqjgaJpZM4KNg1h
.

@danielmitterdorfer

Copy link
Copy Markdown
Author

Sorry for not being clear: I know how to use make and Mac OS X has support for it but the build script as is cannot build a dynamic library for Mac OS X. So I wondered / asked how this binary has been build (it has not been built with this Makefile). I see that I come up with something that covers both platforms.

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.

2 participants