RFR: 8264762: ByteBuffer.byteOrder(BIG_ENDIAN).asXBuffer.put(Xarray) and ByteBuffer.byteOrder(nativeOrder()).asXBuffer.put(Xarray) are slow [v3]

Brian Burkhalter bpb at openjdk.java.net
Tue Apr 27 19:00:58 UTC 2021


> Please consider this request to accelerate absolute and relative bulk array transfer on views of heap byte buffers where the element size is greater than one. What currently happens is that the transfer devolves to a “loopy” element-by-element copy such as
> 
>         int end = offset + length;
>         for (int i = offset, j = index; i < end; i++, j++)
>             dst[i] = get(j);
> 
> for `get()`, and
> 
>         int end = offset + length;
>         for (int i = offset, j = index; i < end; i++, j++)
>             this.put(j, src[i]);
> 
> for `put()`. This is of course relatively slow.
> 
> The change proposed hoists the accelerated versions of these methods using the `ScopedMemoryAccess` methods `copyMemory()` and `copySwapMemory()` from `Direct-X-Buffer` to `X-Buffer`. The array bulk transfer methods are removed from `Direct-X-Buffer` itself. The number of lines of code in the templates decreases by 87.
> 
> With this change the throughput of array bulk `put()` and `get()` for heap view buffers is increased by a factor of 6 to 11 compared with the current code. The performance of direct view buffers does not appear to be affected.
> 
> No tests are modified or added as existing tests already cover these methods. All tests in CI tiers 1-3 passed on all platforms.

Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:

  8264762: Remove dead code at X-Buffer:799

-------------

Changes:
  - all: https://git.openjdk.java.net/jdk/pull/3660/files
  - new: https://git.openjdk.java.net/jdk/pull/3660/files/719b8d84..bfd374b7

Webrevs:
 - full: https://webrevs.openjdk.java.net/?repo=jdk&pr=3660&range=02
 - incr: https://webrevs.openjdk.java.net/?repo=jdk&pr=3660&range=01-02

  Stats: 1 line in 1 file changed: 0 ins; 1 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3660.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3660/head:pull/3660

PR: https://git.openjdk.java.net/jdk/pull/3660


More information about the nio-dev mailing list