JDK-8265175 : (fs) Files.copy(Path,Path,CopyOption...) should use sendfile on Linux
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2021-04-13
  • Updated: 2025-01-24
  • Resolved: 2021-04-16
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 17
17 b19Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Description
On Unix the copy is implemented in sun.nio.fs.UnixCopyFile.copy() which calls a native method transfer(int,int,long) to perform the actual data copying. The copy is effected via a user-space buffer in a loop of read()-write() invocations. Instead of going via user-space buffers, the copy should be able to be done more efficiently using zero-copy as implemented by the Linux system call sendfile().
Comments
Changeset: 1c3fd46d Author: Brian Burkhalter <bpb@openjdk.org> Date: 2021-04-16 15:46:37 +0000 URL: https://git.openjdk.java.net/jdk/commit/1c3fd46d
16-04-2021

I think it it would be useful to see what "cp" is doing. Also I expect use a buffer size that is a multiple of the block size will improve the existing implementation too.
14-04-2021