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

Brian Burkhalter bpb at openjdk.java.net
Wed Jun 15 00:30:19 UTC 2022


On Wed, 15 Jun 2022 00:20:58 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Modify `UnixCopyFile.copyFile()` to set the transfer size to the least common multiple of the source and destination file block sizes if the block sizes are not equal. Modify `WindowsFileCopy.copy()` to set `COPY_FILE_NO_BUFFERING` in the flags passed to `CopyFileEx()` if the size of the transfer is greater than a threshold.

The value of the threshold used to determine whether `COPY_FILE_NO_BUFFERING` is added to the `copyFlags` parameter of `CopyFileEx()` was determined empirically. An alternative to having a fixed threshold would be to set the threshold dynamically as some fraction of the file system cache [maximum size](https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-getsystemfilecachesize), if set, or of the system [total memory](https://download.java.net/java/early_access/jdk19/docs/api/jdk.management/com/sun/management/OperatingSystemMXBean.html#getTotalMemorySize()).

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

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


More information about the nio-dev mailing list