RFR: 8278166: java/nio/channels/Channels/TransferTo.java timed out
Alan Bateman
alanb at openjdk.java.net
Sat Dec 4 06:53:15 UTC 2021
On Fri, 3 Dec 2021 23:05:42 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
>> test/jdk/java/nio/channels/Channels/TransferTo.java line 150:
>>
>>> 148: try {
>>> 149: // create (hopefully sparse) file less than 2GB in size
>>> 150: final long initLen = (2*1024 - 1)*BYTES_PER_WRITE;
>>
>> Perhaps consider clarifying the comment for the initLen calculation
>>
>> I do suspect the use of RandomAccessFile improves the throughput here
>
> I shall clean up the constants in the next revision.
>
> A crude measurement showed that the execution time of `testMoreThanTwoGB()` was cut in half by this change. This sub-test is the slowest `@Test` in the test.
The general approach looks okay but the RAF to open/setLength/close is not needed. Instead change the FC.open to use WRITE and use fc.position(initLen) to set the initial position before writing.
-------------
PR: https://git.openjdk.java.net/jdk/pull/6707
More information about the nio-dev
mailing list