1

I am sending large amounts of data from Java to C++ using JNI and in an attempt to minimize the cost of transferring the data and avoid unnecessary copies, I tried implementing GetDirectBufferAddress to access the memory location directly instead of GetDoubleArrayElements. I also ran performance metrics on both methods from the Java side via System.currentTimeMillis() and got the following performance times:

GetDoubleArrayElements: 98 ms GetDirectBufferAddress: 96 ms

Virtually no performance increase. Is there any reason this might be happening? I allocated the ByteBuffers on the Java side using ByteBuffer.allocateDirect().order(ByteOrder.nativeOrder) and arrBuff.putDouble(arr[i]). Am I missing something? Any reference material would be greatly appreciated, I'm just trying to learn.

C. Wallace
  • 11
  • 3
  • 1
    What is your transfer speed in bytes/second? Are you close to the actual limits of hardware on your system? Is there any reason you think you actually can go faster? – markspace Jul 25 '18 at 19:23
  • 1
    You should make sure you're benchmarking properly first. See for example https://stackoverflow.com/q/504103/2891664 and https://www.ibm.com/developerworks/java/library/j-jtp02225/ (Using `currentTimeMillis` isn't a good idea, for starters.) – Radiodef Jul 25 '18 at 19:32
  • Hardware: Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz, 64 bit – C. Wallace Jul 25 '18 at 19:34

0 Answers0