Add slice copy support for socket file type.
Splice can be used to speed up file copy operations
by avoiding moving any memory between kernel/user space.
But splice copy can not support from socket file to
regular/socket file directly. So use pipe file as proxy,
socket/regular --> pipe --> socket/regular. Even it needs
2 times splice syscall, it is still much faster
than user space copy.
Please refer to the comparison data below for the time
consumption of executing FileUtils.copy in
FileUtilsTest:testCopy_SocketToFile_FileToSocket
file-->socket(unit ms):
32KB: user_cp:0.604, splice_cp:0.113, reduce 80%
32MB: user_cp:236, splice_cp:68, reduce 71%
socket-->file(unit ms):
32KB: user_cp:0.611, splice_cp:0.240, reduce 61%
32MB: user_cp:284, splice_cp:88, reduce 69%
The network environment for this test is localhost,
and the data in real scenarios depends more
on the actual network environment.
Test: atest FrameworksCoreTests:android.os.FileUtilsTest
Change-Id: I0636647934a889ce95bdf4df0db428cb370148fd
Signed-off-by: lizhigang <lizhigang.1220@bytedance.com>
Loading
Please register or sign in to comment