RFR: 6980847: (fs) Files.copy needs to be tuned [v5]

Brian Burkhalter bpb at openjdk.org
Fri Jun 17 15:30:00 UTC 2022


On Fri, 17 Jun 2022 12:03:39 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Brian Burkhalter has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   6980847: Use temporary direct buffer for user-space copy
>
> src/java.base/unix/classes/sun/nio/fs/UnixCopyFile.java line 315:
> 
>> 313:                         if (buf != null) {
>> 314:                             Util.releaseTemporaryDirectBuffer(buf);
>> 315:                         }
> 
> I don't think this is maintainable as is, instead I think the two cases need to moved to supporting methods so you can have something like:
> 
> 
> if (transferRequiresBuffer) {
>     transferWithTemporyBuffer(...);
> } else {
>     transferDirect(...)
> }

I wrote something like that before publishing this version and did not like it but now I think it might be better.

> src/java.base/unix/native/libnio/fs/UnixCopyFile.c line 158:
> 
>> 156:             if (errno == EINVAL || errno == ENOSYS) {
>> 157:                 // Fall back to copying via user-space buffers
>> 158:                 char buf[MIN_TRANSFER_SIZE];
> 
> We can't have the fallback path using 16k of stack here.

That code is likely never called.

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

PR: https://git.openjdk.org/jdk/pull/9161


More information about the nio-dev mailing list