On Wed, 3 Aug 2022 17:14:13 GMT, Brian Burkhalter <b...@openjdk.org> wrote:
>> Modify native multi-byte read-write code used by the `java.io` classes to >> limit the size of the allocated native buffer thereby decreasing off-heap >> memory footprint and increasing throughput. > > Brian Burkhalter has updated the pull request with a new target base due to a > merge or a rebase. The incremental webrev excludes the unrelated changes > brought in by the merge/rebase. The pull request contains 14 additional > commits since the last revision: > > - 6478546: Eliminate a subtraction from RandomAccessFile.bufferSize() > - Merge > - 6478546: Miscellaneous cleanup > - Merge > - Merge > - 6478546: Use dynamically sized temporary direct buffers > - Merge > - Merge > - 6478546: Add break in write loop on ExceptionOccurred > - Merge > - ... and 4 more: https://git.openjdk.org/jdk/compare/50a06466...9d7e4fbf Using the temporary direct buffer cache to provide intermediate native memory is not a good solution as direct memory may be limited. Hence the patch is reverted to its prior state, modified to move parameter checking up to the Java layer, and simplified to keep `Blocker` use to within the `readBytes` and `writeBytes` methods. This patch uses less memory and has generally higher throughput than the master branch. Sample benchmark measurements on macOS are as follows: RandomAccessFile::read(byte[]) ops / sec length master patch 16384 468119.718 501174.185 32768 328305.094 353844.578 262144 48575.747 52739.050 1048576 13176.250 13723.486 10485760 378.469 596.246 251503002 10.554 20.784 524288000 5.095 10.014 1000000000 1.743 5.254 RandomAccessFile::write(byte[]) ops / sec length master patch 16384 328584.712 353691.078 32768 252836.010 276133.188 262144 46072.526 38558.946 1048576 12908.426 9716.200 10485760 194.396 498.384 251503002 7.649 18.175 524288000 3.643 8.524 1000000000 1.202 4.491 ------------- PR: https://git.openjdk.org/jdk/pull/8235